diff options
author | jcorgan | 2008-03-24 15:58:45 +0000 |
---|---|---|
committer | jcorgan | 2008-03-24 15:58:45 +0000 |
commit | 5a477a01798fa49a6d0d69debfb2e64c1ded5083 (patch) | |
tree | 6e2aa1f4a1cf76980e70940dd591fcac6050907e /gnuradio-core/src | |
parent | 8d51a86a61448f746a3193f710b0beb7a0143f96 (diff) | |
download | gnuradio-5a477a01798fa49a6d0d69debfb2e64c1ded5083.tar.gz gnuradio-5a477a01798fa49a6d0d69debfb2e64c1ded5083.tar.bz2 gnuradio-5a477a01798fa49a6d0d69debfb2e64c1ded5083.zip |
Fixed gr.udp_source,sink for use on Win32 (Don Ward)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8097 221aa14e-8319-0410-a670-987f0aec2ac5
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r-- | gnuradio-core/src/lib/io/gr_udp_sink.cc | 11 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_udp_sink.h | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_udp_source.cc | 13 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_udp_source.h | 5 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/io.i | 4 |
5 files changed, 33 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 15bcf9a83..82cd5c29f 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.cc +++ b/gnuradio-core/src/lib/io/gr_udp_sink.cc @@ -26,7 +26,14 @@ #include <gr_udp_sink.h> #include <gr_io_signature.h> #include <stdexcept> +#if defined(HAVE_SOCKET) #include <netdb.h> +typedef void* optval_t; +#else +#define SHUT_RDWR 2 +#define inet_aton(N,A) ( (A)->s_addr = inet_addr(N), ( (A)->s_addr != INADDR_NONE ) ) +typedef char* optval_t; +#endif #define SNK_VERBOSE 0 @@ -112,7 +119,7 @@ gr_udp_sink::open() // Turn on reuse address int opt_val = true; - if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (void*)&opt_val, sizeof(int)) == -1) { + if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (optval_t)&opt_val, sizeof(int)) == -1) { perror("SO_REUSEADDR"); throw std::runtime_error("can't set socket option SO_REUSEADDR"); } @@ -121,7 +128,7 @@ gr_udp_sink::open() linger lngr; lngr.l_onoff = 1; lngr.l_linger = 0; - if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (void*)&lngr, sizeof(linger)) == -1) { + 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"); } diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.h b/gnuradio-core/src/lib/io/gr_udp_sink.h index 4f08136ec..e59380011 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.h +++ b/gnuradio-core/src/lib/io/gr_udp_sink.h @@ -25,9 +25,13 @@ #include <gr_sync_block.h> #include <omnithread.h> +#if defined(HAVE_SOCKET) #include <sys/socket.h> #include <arpa/inet.h> -#include <sys/socket.h> +#elif defined(HAVE_WINDOWS_H) +#include <winsock2.h> +#include <windows.h> +#endif #if defined(HAVE_NETINET_IN_H) #include <netinet/in.h> #endif diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc index f7f04d3cf..c65947ba6 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.cc +++ b/gnuradio-core/src/lib/io/gr_udp_source.cc @@ -27,7 +27,14 @@ #include <gr_io_signature.h> #include <stdexcept> #include <errno.h> +#if defined(HAVE_SOCKET) #include <netdb.h> +typedef void* optval_t; +#else +#define SHUT_RDWR 2 +#define inet_aton(N,A) ( (A)->s_addr = inet_addr(N), ( (A)->s_addr != INADDR_NONE ) ) +typedef char* optval_t; +#endif #define SRC_VERBOSE 0 @@ -91,7 +98,7 @@ gr_udp_source::open() // Turn on reuse address int opt_val = 1; - if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (void*)&opt_val, sizeof(int)) == -1) { + if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (optval_t)&opt_val, sizeof(int)) == -1) { perror("SO_REUSEADDR"); throw std::runtime_error("can't set socket option SO_REUSEADDR"); } @@ -100,7 +107,7 @@ gr_udp_source::open() linger lngr; lngr.l_onoff = 1; lngr.l_linger = 0; - if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (void*)&lngr, sizeof(linger)) == -1) { + 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"); } @@ -110,7 +117,7 @@ gr_udp_source::open() timeval timeout; timeout.tv_sec = 1; timeout.tv_usec = 0; - if(setsockopt(d_socket, SOL_SOCKET, SO_RCVTIMEO, (void*)&timeout, sizeof(timeout)) == -1) { + if(setsockopt(d_socket, SOL_SOCKET, SO_RCVTIMEO, (optval_t)&timeout, sizeof(timeout)) == -1) { perror("SO_RCVTIMEO"); throw std::runtime_error("can't set socket option SO_RCVTIMEO"); } diff --git a/gnuradio-core/src/lib/io/gr_udp_source.h b/gnuradio-core/src/lib/io/gr_udp_source.h index 83bebf84d..a4403c3d6 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.h +++ b/gnuradio-core/src/lib/io/gr_udp_source.h @@ -25,8 +25,13 @@ #include <gr_sync_block.h> #include <omnithread.h> +#if defined(HAVE_SOCKET) #include <sys/socket.h> #include <arpa/inet.h> +#elif defined(HAVE_WINDOWS_H) +#include <winsock2.h> +#include <windows.h> +#endif #if defined(HAVE_NETINET_IN_H) #include <netinet/in.h> #endif diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i index 63dd979ff..ed7feb49d 100644 --- a/gnuradio-core/src/lib/io/io.i +++ b/gnuradio-core/src/lib/io/io.i @@ -22,6 +22,10 @@ %{ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include <gr_file_sink.h> #include <gr_file_source.h> #include <gr_file_descriptor_sink.h> |