[PD] netreceive patch

CK x at meta.lo-res.org
Mon Dec 22 10:04:52 CET 2003


hi,

I've just done a little patch to netreceive that introduces a third floatarg
which is just a flag to enable loopback only mode (for us paranoid people)
shouldn't break existing patches but I only tested on linux (though I don't
see why it shouldn't work on any other *nix, someone on win please test if
this needs to be #ifdef'ed)

regards,

x

-- 
chris at lo-res.org	Postmodernism is german romanticism with better
http://pilot.fm/	special effects. (Jeff Keuss / via ctheory.com)
-------------- next part --------------
--- pd-0.37-0/src/x_net.c	2003-03-21 07:36:20.000000000 +0100
+++ pd-0.37-0-x/src/x_net.c	2003-12-22 09:51:49.547469488 +0100
@@ -249,11 +249,11 @@
 }
 
 static void *netreceive_new(t_symbol *compatflag,
-    t_floatarg fportno, t_floatarg udpflag)
+    t_floatarg fportno, t_floatarg udpflag, t_floatarg loflag)
 {
     t_netreceive *x;
     struct sockaddr_in server;
-    int sockfd, portno = fportno, udp = (udpflag != 0);
+    int sockfd, portno = fportno, udp = (udpflag != 0), lo = (loflag != 0);
     int old = !strcmp(compatflag->s_name , "old");
     int intarg;
     	/* create a socket */
@@ -267,7 +267,7 @@
     	return (0);
     }
     server.sin_family = AF_INET;
-    server.sin_addr.s_addr = INADDR_ANY;
+    server.sin_addr.s_addr = (lo ? INADDR_LOOPBACK : INADDR_ANY);
 
 #if 1
     	/* ask OS to allow another Pd to repoen this port after we close it. */
@@ -352,7 +352,7 @@
     netreceive_class = class_new(gensym("netreceive"),
     	(t_newmethod)netreceive_new, (t_method)netreceive_free,
     	sizeof(t_netreceive), CLASS_NOINLET, A_DEFFLOAT, A_DEFFLOAT, 
-	    A_DEFSYM, 0);
+	    A_DEFFLOAT, A_DEFSYM, 0);
 }
 
 void x_net_setup(void)


More information about the Pd-list mailing list