summaryrefslogtreecommitdiff
path: root/gnuradio-core
diff options
context:
space:
mode:
authorDon Ward2010-04-19 17:02:14 -0400
committerDon Ward2010-04-20 10:37:59 -0400
commit3b8fcaa640d75573d314fb8616969ad2adf2a099 (patch)
treed505471a8ff3a25ac38b56c8a0f350c0e2273dcf /gnuradio-core
parentd1ae6560ab2b8b5d474e58f865314a6cf18b958c (diff)
downloadgnuradio-3b8fcaa640d75573d314fb8616969ad2adf2a099.tar.gz
gnuradio-3b8fcaa640d75573d314fb8616969ad2adf2a099.tar.bz2
gnuradio-3b8fcaa640d75573d314fb8616969ad2adf2a099.zip
Discard data in gr_udp_sink until receiver is started.
Also fixes warnings from gcc 4.3 and adds <boost/bind.hpp> for usrp2.
Diffstat (limited to 'gnuradio-core')
-rwxr-xr-xgnuradio-core/src/lib/io/gr_udp_sink.cc17
-rwxr-xr-xgnuradio-core/src/lib/io/gr_udp_source.cc2
2 files changed, 13 insertions, 6 deletions
diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.cc b/gnuradio-core/src/lib/io/gr_udp_sink.cc
index 3d8d65145..b447dd3b3 100755
--- a/gnuradio-core/src/lib/io/gr_udp_sink.cc
+++ b/gnuradio-core/src/lib/io/gr_udp_sink.cc
@@ -36,7 +36,6 @@ typedef void* optval_t;
#define USING_WINSOCK
#define SHUT_RDWR 2
typedef char* optval_t;
-#define ENOPROTOOPT 109
#endif
#include <gruel/thread.h>
@@ -47,6 +46,8 @@ static int is_error( int perr )
{
// Compare error to posix error code; return nonzero if match.
#if defined(USING_WINSOCK)
+#define ENOPROTOOPT 109
+#define ECONNREFUSED 111
// All codes to be checked for must be defined below
int werr = WSAGetLastError();
switch( werr ) {
@@ -54,6 +55,8 @@ static int is_error( int perr )
return( perr == EAGAIN );
case WSAENOPROTOOPT:
return( perr == ENOPROTOOPT );
+ case WSAECONNREFUSED:
+ return( perr == ECONNREFUSED );
default:
fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr );
throw std::runtime_error("internal error");
@@ -64,7 +67,7 @@ static int is_error( int perr )
#endif
}
-static void report_error( char *msg1, char *msg2 )
+static void report_error( const char *msg1, const char *msg2 )
{
// Deal with errors, both posix and winsock
#if defined(USING_WINSOCK)
@@ -217,7 +220,7 @@ gr_udp_sink::work (int noutput_items,
ssize_t total_size = noutput_items*d_itemsize;
#if SNK_VERBOSE
- printf("Entered upd_sink\n");
+ printf("Entered udp_sink\n");
#endif
while(bytes_sent < total_size) {
@@ -225,8 +228,12 @@ gr_udp_sink::work (int noutput_items,
r = send(d_socket, (in+bytes_sent), bytes_to_send, 0);
if(r == -1) { // error on send command
- report_error("udp_sink",NULL); // there should be no error case where
- return -1; // this function should not exit immediately
+ if( is_error(ECONNREFUSED) )
+ r = bytes_to_send; // discard data until receiver is started
+ else {
+ report_error("udp_sink",NULL); // there should be no error case where
+ return -1; // this function should not exit immediately
+ }
}
bytes_sent += r;
diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc
index f459e7f13..56499258c 100755
--- a/gnuradio-core/src/lib/io/gr_udp_source.cc
+++ b/gnuradio-core/src/lib/io/gr_udp_source.cc
@@ -36,7 +36,6 @@ typedef void* optval_t;
#define USING_WINSOCK
#define SHUT_RDWR 2
typedef char* optval_t;
-#define ENOPROTOOPT 109
#endif
#define SRC_VERBOSE 0
@@ -45,6 +44,7 @@ static int is_error( int perr )
{
// Compare error to posix error code; return nonzero if match.
#if defined(USING_WINSOCK)
+#define ENOPROTOOPT 109
// All codes to be checked for must be defined below
int werr = WSAGetLastError();
switch( werr ) {