diff options
author | Don Ward | 2010-04-15 14:37:04 -0400 |
---|---|---|
committer | Don Ward | 2010-04-15 14:37:04 -0400 |
commit | b0d32c6c20cadaa544aeaa7b5257919674e8d0ad (patch) | |
tree | 13704558b96d78a8bb5523ece3bde49d62dc9aca | |
parent | 213f8bcef70281a52bab02d2a9e7868749530c3c (diff) | |
download | gnuradio-b0d32c6c20cadaa544aeaa7b5257919674e8d0ad.tar.gz gnuradio-b0d32c6c20cadaa544aeaa7b5257919674e8d0ad.tar.bz2 gnuradio-b0d32c6c20cadaa544aeaa7b5257919674e8d0ad.zip |
Ignore ENOPROTOOPT return from setsockopt(SO_LINGER)
SO_LINGER is not valid for SOCK_DGRAM sockets on Windows, so we
expect setsockopt to return ENOPROTOOPT (invalid option for
protocol) on Cygwin and MinGW. If it happens on any other system
it should probably be ignored there, too.
-rwxr-xr-x[-rw-r--r--] | gnuradio-core/src/lib/io/gr_udp_sink.cc | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | gnuradio-core/src/lib/io/gr_udp_source.cc | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.cc b/gnuradio-core/src/lib/io/gr_udp_sink.cc index d37adfb8a..a837e731e 100644..100755 --- a/gnuradio-core/src/lib/io/gr_udp_sink.cc +++ b/gnuradio-core/src/lib/io/gr_udp_sink.cc @@ -132,8 +132,10 @@ gr_udp_sink::open() lngr.l_onoff = 1; lngr.l_linger = 0; if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) { - perror("SO_LINGER"); - throw std::runtime_error("can't set socket option SO_LINGER"); + if(errno != ENOPROTOOPT) { // no SO_LINGER for SOCK_DGRAM on Windows + perror("SO_LINGER"); + throw std::runtime_error("can't set socket option SO_LINGER"); + } } // bind socket to an address and port number to listen on diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc index d76d0ee32..fed5b6142 100644..100755 --- a/gnuradio-core/src/lib/io/gr_udp_source.cc +++ b/gnuradio-core/src/lib/io/gr_udp_source.cc @@ -110,8 +110,10 @@ gr_udp_source::open() lngr.l_onoff = 1; lngr.l_linger = 0; if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) { - perror("SO_LINGER"); - throw std::runtime_error("can't set socket option SO_LINGER"); + if(errno != ENOPROTOOPT) { // no SO_LINGER for SOCK_DGRAM on Windows + perror("SO_LINGER"); + throw std::runtime_error("can't set socket option SO_LINGER"); + } } // Set a timeout on the receive function to not block indefinitely |