GNU Radio Manual and C++ API Reference  v3.9.2.0-89-gb7c7001e
The Free & Open Software Radio Ecosystem
gr-blocks/include/gnuradio/blocks/udp_source.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2007-2010,2013,2015 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_SOURCE_H
12 #define INCLUDED_GR_UDP_SOURCE_H
13 
14 #include <gnuradio/blocks/api.h>
15 #include <gnuradio/sync_block.h>
16 
17 namespace gr {
18 namespace blocks {
19 
20 /*!
21  * \brief Read stream from an UDP socket.
22  * \ingroup networking_tools_blk
23  */
24 class BLOCKS_API udp_source : virtual public sync_block
25 {
26 public:
27  // gr::blocks::udp_source::sptr
28  typedef std::shared_ptr<udp_source> sptr;
29 
30  /*!
31  * \brief UDP Source Constructor
32  *
33  * \param itemsize The size (in bytes) of the item datatype
34  * \param host The name or IP address of the transmitting host; can be
35  * NULL, None, or "0.0.0.0" to allow reading from any
36  * interface on the host
37  * \param port The port number on which to receive data; use 0 to
38  * have the system assign an unused port number
39  * \param payload_size UDP payload size by default set to 1472 =
40  * (1500 MTU - (8 byte UDP header) - (20 byte IP header))
41  * \param eof Interpret zero-length packet as EOF (default: true)
42  */
43  static sptr make(size_t itemsize,
44  const std::string& host,
45  int port,
46  int payload_size = 1472,
47  bool eof = true);
48 
49  /*! \brief Change the connection to a new destination
50  *
51  * \param host The name or IP address of the receiving host; use
52  * NULL or None to break the connection without closing
53  * \param port Destination port to connect to on receiving host
54  *
55  * Calls disconnect() to terminate any current connection first.
56  */
57  virtual void connect(const std::string& host, int port) = 0;
58 
59  /*! \brief Cut the connection if we have one set up.
60  */
61  virtual void disconnect() = 0;
62 
63  /*! \brief return the PAYLOAD_SIZE of the socket */
64  virtual int payload_size() = 0;
65 
66  /*! \brief return the port number of the socket */
67  virtual int get_port() = 0;
68 };
69 
70 } /* namespace blocks */
71 } /* namespace gr */
72 
73 #endif /* INCLUDED_GR_UDP_SOURCE_H */
Read stream from an UDP socket.
Definition: gr-blocks/include/gnuradio/blocks/udp_source.h:25
virtual void connect(const std::string &host, int port)=0
Change the connection to a new destination.
std::shared_ptr< udp_source > sptr
Definition: gr-blocks/include/gnuradio/blocks/udp_source.h:28
virtual int get_port()=0
return the port number of the socket
static sptr make(size_t itemsize, const std::string &host, int port, int payload_size=1472, bool eof=true)
UDP Source Constructor.
virtual int payload_size()=0
return the PAYLOAD_SIZE of the socket
virtual void disconnect()=0
Cut the connection if we have one set up.
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