GNU Radio Manual and C++ API Reference 3.10.1.1
The Free & Open Software Radio Ecosystem
socket_pdu_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2013 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef INCLUDED_NETWORK_SOCKET_PDU_IMPL_H
12#define INCLUDED_NETWORK_SOCKET_PDU_IMPL_H
13
14#include "tcp_connection.h"
16
17namespace gr {
18namespace network {
19
21{
22private:
23 boost::asio::io_service d_io_service;
24 std::vector<char> d_rxbuf;
25 void run_io_service() { d_io_service.run(); }
26 gr::thread::thread d_thread;
27 bool d_started;
28
29 // TCP specific
30 boost::asio::ip::tcp::endpoint d_tcp_endpoint;
31 std::vector<tcp_connection::sptr> d_tcp_connections;
32 void handle_tcp_read(const boost::system::error_code& error,
33 size_t bytes_transferred);
34 const bool d_tcp_no_delay;
35
36 // TCP server specific
37 std::shared_ptr<boost::asio::ip::tcp::acceptor> d_acceptor_tcp;
38 void start_tcp_accept();
39 void tcp_server_send(pmt::pmt_t msg);
40 void handle_tcp_accept(tcp_connection::sptr new_connection,
41 const boost::system::error_code& error);
42
43 // TCP client specific
44 std::shared_ptr<boost::asio::ip::tcp::socket> d_tcp_socket;
45 void tcp_client_send(pmt::pmt_t msg);
46
47 // UDP specific
48 boost::asio::ip::udp::endpoint d_udp_endpoint;
49 boost::asio::ip::udp::endpoint d_udp_endpoint_other;
50 std::shared_ptr<boost::asio::ip::udp::socket> d_udp_socket;
51 void handle_udp_read(const boost::system::error_code& error,
52 size_t bytes_transferred);
53 void udp_send(pmt::pmt_t msg);
54
55public:
56 socket_pdu_impl(std::string type,
57 std::string addr,
58 std::string port,
59 int MTU = 10000,
60 bool tcp_no_delay = false);
61 ~socket_pdu_impl() override;
62 bool stop() override;
63};
64
65} /* namespace network */
66} /* namespace gr */
67
68#endif /* INCLUDED_NETWORK_SOCKET_PDU_IMPL_H */
Definition: socket_pdu_impl.h:21
socket_pdu_impl(std::string type, std::string addr, std::string port, int MTU=10000, bool tcp_no_delay=false)
bool stop() override
Called to disable drivers, etc for i/o devices.
Creates socket interface and translates traffic to PDUs.
Definition: socket_pdu.h:25
std::shared_ptr< tcp_connection > sptr
Definition: tcp_connection.h:40
GR_RUNTIME_API const pmt::pmt_t msg()
boost::thread thread
Definition: thread.h:36
GNU Radio logging wrapper.
Definition: basic_block.h:29
std::shared_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting).
Definition: pmt.h:84