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_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  * 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_SINK_H
24 #define INCLUDED_GR_UDP_SINK_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 Write stream to an UDP socket.
34  * \ingroup networking_tools_blk
35  */
36  class BLOCKS_API udp_sink : virtual public sync_block
37  {
38  public:
39  // gr::blocks::udp_sink::sptr
41 
42  /*!
43  * \brief UDP Sink 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; use
47  * NULL or None for no connection
48  * \param port Destination port to connect to on receiving host
49  * \param payload_size UDP payload size by default set to
50  * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header))
51  * \param eof Send zero-length packet on disconnect
52  */
53  static sptr make(size_t itemsize,
54  const std::string &host, int port,
55  int payload_size=1472, bool eof=true);
56 
57  /*! \brief return the PAYLOAD_SIZE of the socket */
58  virtual int payload_size() = 0;
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 Send zero-length packet (if eof is requested) then stop sending
71  *
72  * Zero-byte packets can be interpreted as EOF by gr_udp_source.
73  * Note that disconnect occurs automatically when the sink is
74  * destroyed, but not when its top_block stops.*/
75  virtual void disconnect() = 0;
76  };
77 
78  } /* namespace blocks */
79 } /* namespace gr */
80 
81 #endif /* INCLUDED_GR_UDP_SINK_H */
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
Write stream to an UDP socket.
Definition: udp_sink.h:36
boost::shared_ptr< udp_sink > sptr
Definition: udp_sink.h:40
BLOCKS_API size_t itemsize(vector_type type)