$OpenBSD: patch-tools_netsource_c,v 1.2 2008/06/28 05:49:31 jakemsr Exp $
--- tools/netsource.c.orig	Sat Apr 19 17:35:52 2008
+++ tools/netsource.c	Mon Jun 16 18:38:25 2008
@@ -30,11 +30,15 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, U
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
+#include <fcntl.h>
 
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <netdb.h>
 
+#ifdef HAVE_ALLOCA_H
 #include <alloca.h>
+#endif
 
 #include <jack/jack.h>
 
@@ -206,10 +210,11 @@ process (jack_nframes_t nframes, void *arg)
 
     /* ---------- Receive ---------- */
     if (reply_port)
-        size = netjack_recv (insockfd, (char *) packet_buf, rx_bufsize, MSG_DONTWAIT, mtu);
+        size = netjack_recv (insockfd, (char *) packet_buf, rx_bufsize, NULL, mtu);
     else
-        size = netjack_recv (outsockfd, (char *) packet_buf, rx_bufsize, MSG_DONTWAIT, mtu);
+        size = netjack_recv (outsockfd, (char *) packet_buf, rx_bufsize, NULL, mtu);
     packet_header_ntoh (pkthdr);
+
     /* Loop till we get the right packet at the right momment */
     while (size == rx_bufsize && (framecnt - pkthdr->framecnt) > latency)
     {
@@ -217,9 +222,9 @@ process (jack_nframes_t nframes, void *arg)
         //printf ("Frame %d  \tLate packet received with a latency of %d frames\n", framecnt, framecnt - pkthdr->framecnt);
 
         if (reply_port)
-            size = netjack_recv (insockfd, (char *) packet_buf, rx_bufsize, MSG_DONTWAIT, mtu);
+            size = netjack_recv (insockfd, (char *) packet_buf, rx_bufsize, NULL, mtu);
         else
-            size = netjack_recv (outsockfd, (char *) packet_buf, rx_bufsize, MSG_DONTWAIT, mtu);
+            size = netjack_recv (outsockfd, (char *) packet_buf, rx_bufsize, NULL, mtu);
         packet_header_ntoh (pkthdr);
     }
 
@@ -367,6 +372,7 @@ main (int argc, char *argv[])
     int peer_port = 3000;
     jack_options_t options = JackNullOption;
     jack_status_t status;
+    int ff;
 
     /* Torben's famous state variables, aka "the reporting API" ! */
     int statecopy_connected, statecopy_latency, statecopy_netxruns;
@@ -471,6 +477,11 @@ main (int argc, char *argv[])
                          "Is the JACK server running ?\n", status);
         return 1;
     }
+
+    fcntl(outsockfd, F_GETFL, &ff);
+    fcntl(outsockfd, F_SETFL, ff | O_NONBLOCK);
+    fcntl(insockfd, F_GETFL, &ff);
+    fcntl(insockfd, F_SETFL, ff | O_NONBLOCK);
 
     /* Set up jack callbacks */
     jack_set_process_callback (client, process, 0);
