GNU Radio Manual and C++ API Reference  3.7.4
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
udp_source.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  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_GR_UDP_SOURCE_H
24 #define INCLUDED_GR_UDP_SOURCE_H
25 
26 #include <gnuradio/blocks/api.h>
27 #include <gnuradio/sync_block.h>
28 
29 namespace gr {
30  namespace blocks {
31 
32  /*!
33  * \brief Read stream from an UDP socket.
34  * \ingroup networking_tools_blk
35  */
36  class BLOCKS_API udp_source : virtual public sync_block
37  {
38  public:
39  // gr::blocks::udp_source::sptr
41 
42  /*!
43  * \brief UDP Source Constructor
44  *
45  * \param itemsize The size (in bytes) of the item datatype
46  * \param host The name or IP address of the receiving host; can be
47  * NULL, None, or "0.0.0.0" to allow reading from any
48  * interface on the host
49  * \param port The port number on which to receive data; use 0 to
50  * have the system assign an unused port number
51  * \param payload_size UDP payload size by default set to 1472 =
52  * (1500 MTU - (8 byte UDP header) - (20 byte IP header))
53  * \param eof Interpret zero-length packet as EOF (default: true)
54  */
55  static sptr make(size_t itemsize,
56  const std::string &host, int port,
57  int payload_size=1472,
58  bool eof=true);
59 
60  /*! \brief Change the connection to a new destination
61  *
62  * \param host The name or IP address of the receiving host; use
63  * NULL or None to break the connection without closing
64  * \param port Destination port to connect to on receiving host
65  *
66  * Calls disconnect() to terminate any current connection first.
67  */
68  virtual void connect(const std::string &host, int port) = 0;
69 
70  /*! \brief Cut the connection if we have one set up.
71  */
72  virtual void disconnect() = 0;
73 
74  /*! \brief return the PAYLOAD_SIZE of the socket */
75  virtual int payload_size() = 0;
76 
77  /*! \brief return the port number of the socket */
78  virtual int get_port() = 0;
79  };
80 
81  } /* namespace blocks */
82 } /* namespace gr */
83 
84 #endif /* INCLUDED_GR_UDP_SOURCE_H */
Read stream from an UDP socket.
Definition: udp_source.h:36
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:30
synchronous 1:1 input to output with historyOverride work to provide the signal processing implementa...
Definition: sync_block.h:37
boost::shared_ptr< udp_source > sptr
Definition: udp_source.h:40
BLOCKS_API size_t itemsize(vector_type type)