GNU Radio Manual and C++ API Reference 3.8.5.0
The Free & Open Software Radio Ecosystem
 
Loading...
Searching...
No Matches
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 * 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
29namespace gr {
30namespace blocks {
31
32/*!
33 * \brief Read stream from an UDP socket.
34 * \ingroup networking_tools_blk
35 */
36class BLOCKS_API udp_source : virtual public sync_block
37{
38public:
39 // gr::blocks::udp_source::sptr
40 typedef boost::shared_ptr<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 transmitting 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,
57 int port,
58 int payload_size = 1472,
59 bool eof = true);
60
61 /*! \brief Change the connection to a new destination
62 *
63 * \param host The name or IP address of the receiving host; use
64 * NULL or None to break the connection without closing
65 * \param port Destination port to connect to on receiving host
66 *
67 * Calls disconnect() to terminate any current connection first.
68 */
69 virtual void connect(const std::string& host, int port) = 0;
70
71 /*! \brief Cut the connection if we have one set up.
72 */
73 virtual void disconnect() = 0;
74
75 /*! \brief return the PAYLOAD_SIZE of the socket */
76 virtual int payload_size() = 0;
77
78 /*! \brief return the port number of the socket */
79 virtual int get_port() = 0;
80};
81
82} /* namespace blocks */
83} /* namespace gr */
84
85#endif /* INCLUDED_GR_UDP_SOURCE_H */
Read stream from an UDP socket.
Definition udp_source.h:37
virtual void connect(const std::string &host, int port)=0
Change the connection to a new destination.
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.
boost::shared_ptr< udp_source > sptr
Definition udp_source.h:40
synchronous 1:1 input to output with history
Definition sync_block.h:38
#define BLOCKS_API
Definition gr-blocks/include/gnuradio/blocks/api.h:30
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition basic_block.h:46