GNU Radio 3.6.4.1 C++ API
gr_udp_sink.h
Go to the documentation of this file.
1
/* -*- c++ -*- */
2
/*
3
* Copyright 2007,2008,2009,2010 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 <
gr_core_api.h
>
27
#include <
gr_sync_block.h
>
28
#include <
gruel/thread.h
>
29
30
class
gr_udp_sink
;
31
typedef
boost::shared_ptr<gr_udp_sink>
gr_udp_sink_sptr
;
32
33
GR_CORE_API
gr_udp_sink_sptr
34
gr_make_udp_sink
(
size_t
itemsize,
35
const
char
*host,
unsigned
short
port,
36
int
payload_size
=1472,
bool
eof=
true
);
37
38
/*!
39
* \brief Write stream to an UDP socket.
40
* \ingroup sink_blk
41
*
42
* \param itemsize The size (in bytes) of the item datatype
43
* \param host The name or IP address of the receiving host; use
44
* NULL or None for no connection
45
* \param port Destination port to connect to on receiving host
46
* \param payload_size UDP payload size by default set to 1472 =
47
* (1500 MTU - (8 byte UDP header) - (20 byte IP header))
48
* \param eof Send zero-length packet on disconnect
49
*/
50
51
class
GR_CORE_API
gr_udp_sink
:
public
gr_sync_block
52
{
53
friend
GR_CORE_API
gr_udp_sink_sptr
gr_make_udp_sink
(
size_t
itemsize,
54
const
char
*host,
55
unsigned
short
port,
56
int
payload_size,
bool
eof);
57
private
:
58
size_t
d_itemsize;
59
60
int
d_payload_size;
// maximum transmission unit (packet length)
61
bool
d_eof;
// send zero-length packet on disconnect
62
int
d_socket;
// handle to socket
63
bool
d_connected;
// are we connected?
64
gruel::mutex
d_mutex;
// protects d_socket and d_connected
65
66
protected
:
67
/*!
68
* \brief UDP Sink Constructor
69
*
70
* \param itemsize The size (in bytes) of the item datatype
71
* \param host The name or IP address of the receiving host; use
72
* NULL or None for no connection
73
* \param port Destination port to connect to on receiving host
74
* \param payload_size UDP payload size by default set to
75
* 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header))
76
* \param eof Send zero-length packet on disconnect
77
*/
78
gr_udp_sink
(
size_t
itemsize,
79
const
char
*host,
unsigned
short
port,
80
int
payload_size,
bool
eof);
81
82
public
:
83
~
gr_udp_sink
();
84
85
/*! \brief return the PAYLOAD_SIZE of the socket */
86
int
payload_size
() {
return
d_payload_size; }
87
88
/*! \brief Change the connection to a new destination
89
*
90
* \param host The name or IP address of the receiving host; use
91
* NULL or None to break the connection without closing
92
* \param port Destination port to connect to on receiving host
93
*
94
* Calls disconnect() to terminate any current connection first.
95
*/
96
void
connect(
const
char
*host,
unsigned
short
port );
97
98
/*! \brief Send zero-length packet (if eof is requested) then stop sending
99
*
100
* Zero-byte packets can be interpreted as EOF by gr_udp_source. Note that
101
* disconnect occurs automatically when the sink is destroyed, but not when
102
* its top_block stops.*/
103
void
disconnect();
104
105
// should we export anything else?
106
107
int
work
(
int
noutput_items,
108
gr_vector_const_void_star
&input_items,
109
gr_vector_void_star
&output_items);
110
};
111
112
#endif
/* INCLUDED_GR_UDP_SINK_H */
gnuradio
gnuradio-core
src
lib
io
gr_udp_sink.h
Generated by
1.8.1.2