summaryrefslogtreecommitdiff
path: root/gr-network/include/gnuradio/network/tcp_sink.h
blob: 8cbc05fd3bdef917943973177035e4b41451e4a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* -*- c++ -*- */
/*
 * Copyright 2020 Free Software Foundation, Inc.
 *
 * This file is part of GNU Radio
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 */

#ifndef INCLUDED_NETWORK_TCP_SINK_H
#define INCLUDED_NETWORK_TCP_SINK_H

#include <gnuradio/network/api.h>
#include <gnuradio/sync_block.h>

#define TCPSINKMODE_CLIENT 1
#define TCPSINKMODE_SERVER 2

namespace gr {
namespace network {

/*!
 * \brief This block provides a TCP Sink block that supports
 * both client and server modes.
 * \ingroup networking_tools
 *
 * \details
 * This block provides a TCP sink that supports both listening for
 * inbound connections (server mode) and connecting to other applications
 * (client mode) in order to send data from a GNU Radio flowgraph.
 * The block supports both IPv4 and IPv6 with appropriate code determined
 * by the address used.  In server mode, if a client disconnects, the
 * flowgraph will continue to execute.  If/when a new client connection
 * is established, data will then pick up with the current stream for
 * transmission to the new client.
 */
class NETWORK_API tcp_sink : virtual public gr::sync_block
{
public:
    typedef boost::shared_ptr<tcp_sink> sptr;

    /*!
     * Build a tcp_sink block.
     */
    static sptr
    make(size_t itemsize, size_t veclen, const std::string& host, int port, int sinkmode);
};

} // namespace network
} // namespace gr

#endif /* INCLUDED_NETWORK_TCP_SINK_H */