GNU Radio Manual and C++ API Reference 3.9.4.0
The Free & Open Software Radio Ecosystem
gr-blocks/include/gnuradio/blocks/udp_sink.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2007-2010,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_GR_UDP_SINK_H
12#define INCLUDED_GR_UDP_SINK_H
13
14#include <gnuradio/blocks/api.h>
15#include <gnuradio/sync_block.h>
16
17namespace gr {
18namespace blocks {
19
20/*!
21 * \brief Write stream to an UDP socket.
22 * \ingroup networking_tools_blk
23 */
24class BLOCKS_API udp_sink : virtual public sync_block
25{
26public:
27 // gr::blocks::udp_sink::sptr
28 typedef std::shared_ptr<udp_sink> sptr;
29
30 /*!
31 * \brief UDP Sink Constructor
32 *
33 * \param itemsize The size (in bytes) of the item datatype
34 * \param host The name or IP address of the receiving host; use
35 * NULL or None for no connection
36 * \param port Destination port to connect to on receiving host
37 * \param payload_size UDP payload size by default set to
38 * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header))
39 * \param eof Send zero-length packet on disconnect
40 */
41 static sptr make(size_t itemsize,
42 const std::string& host,
43 int port,
44 int payload_size = 1472,
45 bool eof = true);
46
47 /*! \brief return the PAYLOAD_SIZE of the socket */
48 virtual int payload_size() = 0;
49
50 /*! \brief Change the connection to a new destination
51 *
52 * \param host The name or IP address of the receiving host; use
53 * NULL or None to break the connection without closing
54 * \param port Destination port to connect to on receiving host
55 *
56 * Calls disconnect() to terminate any current connection first.
57 */
58 virtual void connect(const std::string& host, int port) = 0;
59
60 /*! \brief Send zero-length packet (if eof is requested) then stop sending
61 *
62 * Zero-byte packets can be interpreted as EOF by gr_udp_source.
63 * Note that disconnect occurs automatically when the sink is
64 * destroyed, but not when its top_block stops.*/
65 virtual void disconnect() = 0;
66};
67
68} /* namespace blocks */
69} /* namespace gr */
70
71#endif /* INCLUDED_GR_UDP_SINK_H */
Write stream to an UDP socket.
Definition: gr-blocks/include/gnuradio/blocks/udp_sink.h:25
virtual void connect(const std::string &host, int port)=0
Change the connection to a new destination.
virtual void disconnect()=0
Send zero-length packet (if eof is requested) then stop sending.
std::shared_ptr< udp_sink > sptr
Definition: gr-blocks/include/gnuradio/blocks/udp_sink.h:28
static sptr make(size_t itemsize, const std::string &host, int port, int payload_size=1472, bool eof=true)
UDP Sink Constructor.
virtual int payload_size()=0
return the PAYLOAD_SIZE of the socket
synchronous 1:1 input to output with history
Definition: sync_block.h:26
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:18
BLOCKS_API size_t itemsize(vector_type type)
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:29