GNU Radio Manual and C++ API Reference  3.8.1.0
The Free & Open Software Radio Ecosystem
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
40  typedef boost::shared_ptr<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,
55  int port,
56  int payload_size = 1472,
57  bool eof = true);
58 
59  /*! \brief return the PAYLOAD_SIZE of the socket */
60  virtual int payload_size() = 0;
61 
62  /*! \brief Change the connection to a new destination
63  *
64  * \param host The name or IP address of the receiving host; use
65  * NULL or None to break the connection without closing
66  * \param port Destination port to connect to on receiving host
67  *
68  * Calls disconnect() to terminate any current connection first.
69  */
70  virtual void connect(const std::string& host, int port) = 0;
71 
72  /*! \brief Send zero-length packet (if eof is requested) then stop sending
73  *
74  * Zero-byte packets can be interpreted as EOF by gr_udp_source.
75  * Note that disconnect occurs automatically when the sink is
76  * destroyed, but not when its top_block stops.*/
77  virtual void disconnect() = 0;
78 };
79 
80 } /* namespace blocks */
81 } /* namespace gr */
82 
83 #endif /* INCLUDED_GR_UDP_SINK_H */
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
#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)