GNU Radio Manual and C++ API Reference  v3.9.2.0-89-gb7c7001e
The Free & Open Software Radio Ecosystem
tcp_sink_impl.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2020 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_TCP_SINK_IMPL_H
12 #define INCLUDED_NETWORK_TCP_SINK_IMPL_H
13 
15 #include <boost/asio.hpp>
16 #include <boost/asio/ip/tcp.hpp>
17 #include <boost/thread/thread.hpp>
18 
19 namespace gr {
20 namespace network {
21 
23 {
24 protected:
25  size_t d_itemsize;
26  size_t d_veclen;
27  std::string d_host;
28  int d_port;
30 
36 
37  size_t d_block_size;
38  bool d_is_ipv6;
39 
40  boost::system::error_code ec;
41 
42  boost::asio::io_service d_io_service;
43  boost::asio::ip::tcp::endpoint d_endpoint;
44  boost::asio::ip::tcp::socket* d_tcpsocket = NULL;
45  boost::asio::ip::tcp::acceptor* d_acceptor = NULL;
46 
48 
49  virtual void connect(bool initial_connection);
50  virtual void run_listener();
51 
52 public:
54  size_t veclen,
55  const std::string& host,
56  int port,
57  int sinkmode = TCPSINKMODE_CLIENT);
58  ~tcp_sink_impl() override;
59 
60  bool stop() override;
61 
62  void accept_handler(boost::asio::ip::tcp::socket* new_connection,
63  const boost::system::error_code& error);
64 
65  int work(int noutput_items,
66  gr_vector_const_void_star& input_items,
67  gr_vector_void_star& output_items) override;
68 };
69 
70 } // namespace network
71 } // namespace gr
72 
73 #endif /* INCLUDED_NETWORK_TCP_SINK_IMPL_H */
Definition: tcp_sink_impl.h:23
bool stop() override
Called to disable drivers, etc for i/o devices.
boost::asio::io_service d_io_service
Definition: tcp_sink_impl.h:42
size_t d_itemsize
Definition: tcp_sink_impl.h:25
int d_sinkmode
Definition: tcp_sink_impl.h:29
bool d_connected
Definition: tcp_sink_impl.h:47
virtual void run_listener()
std::string d_host
Definition: tcp_sink_impl.h:27
size_t d_block_size
Definition: tcp_sink_impl.h:37
void accept_handler(boost::asio::ip::tcp::socket *new_connection, const boost::system::error_code &error)
boost::asio::ip::tcp::endpoint d_endpoint
Definition: tcp_sink_impl.h:43
boost::thread * d_listener_thread
Definition: tcp_sink_impl.h:33
virtual void connect(bool initial_connection)
size_t d_veclen
Definition: tcp_sink_impl.h:26
int d_port
Definition: tcp_sink_impl.h:28
bool d_initial_connection
Definition: tcp_sink_impl.h:35
bool d_stop_thread
Definition: tcp_sink_impl.h:32
boost::system::error_code ec
Definition: tcp_sink_impl.h:40
bool d_thread_running
Definition: tcp_sink_impl.h:31
bool d_is_ipv6
Definition: tcp_sink_impl.h:38
int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) override
just like gr::block::general_work, only this arranges to call consume_each for you
tcp_sink_impl(size_t itemsize, size_t veclen, const std::string &host, int port, int sinkmode=TCPSINKMODE_CLIENT)
bool d_start_new_listener
Definition: tcp_sink_impl.h:34
This block provides a TCP Sink block that supports both client and server modes.
Definition: tcp_sink.h:39
#define NETWORK_API
Definition: gr-network/include/gnuradio/network/api.h:19
BLOCKS_API size_t itemsize(vector_type type)
boost::thread thread
Definition: thread.h:36
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29
#define TCPSINKMODE_CLIENT
Definition: tcp_sink.h:17
std::vector< const void * > gr_vector_const_void_star
Definition: types.h:28
std::vector< void * > gr_vector_void_star
Definition: types.h:27