Fixed gr.udp_source,sink for use on Win32 (Don Ward)
authorjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Mon, 24 Mar 2008 15:58:45 +0000 (15:58 +0000)
committerjcorgan <jcorgan@221aa14e-8319-0410-a670-987f0aec2ac5>
Mon, 24 Mar 2008 15:58:45 +0000 (15:58 +0000)
git-svn-id: http://gnuradio.org/svn/gnuradio/trunk@8097 221aa14e-8319-0410-a670-987f0aec2ac5

gnuradio-core/src/lib/io/gr_udp_sink.cc
gnuradio-core/src/lib/io/gr_udp_sink.h
gnuradio-core/src/lib/io/gr_udp_source.cc
gnuradio-core/src/lib/io/gr_udp_source.h
gnuradio-core/src/lib/io/io.i

index 15bcf9a839d3c8489ea4cd65509ff776c14f85f6..82cd5c29fe029d65dd778e57f2a04a389aa5c847 100644 (file)
 #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");
   }
index 4f08136ec65d49f9ca1a15631a267aa031a26761..e59380011b6ba17c62d65a12ccaa116ed21fae67 100644 (file)
 
 #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
index f7f04d3cf9384b930bbbd74d16b2a4da90ad0c97..c65947ba6caf565fe5a49b6ee7f8505879f6c5a8 100644 (file)
 #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");
   }
index 83bebf84d26d542b2c7f045dfd0d69796eca708b..a4403c3d6da8e4fcfd1a3e2801dccdb74226299a 100644 (file)
 
 #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
index 63dd979ffd9d976f2dcae08ca34813c30194c17b..ed7feb49d388c9eb51346f0049ccc5e7968de755 100644 (file)
 
 %{
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <gr_file_sink.h>
 #include <gr_file_source.h>
 #include <gr_file_descriptor_sink.h>