[PD-cvs] SF.net SVN: pure-data: [10030] trunk/externals/mrpeach/net/udpreceive.c

mrpeach at users.sourceforge.net mrpeach at users.sourceforge.net
Wed Jun 18 19:30:19 CEST 2008


Revision: 10030
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10030&view=rev
Author:   mrpeach
Date:     2008-06-18 10:30:18 -0700 (Wed, 18 Jun 2008)

Log Message:
-----------
Clarify what SO_REUSEADDR is for, no code changes.

Modified Paths:
--------------
    trunk/externals/mrpeach/net/udpreceive.c

Modified: trunk/externals/mrpeach/net/udpreceive.c
===================================================================
--- trunk/externals/mrpeach/net/udpreceive.c	2008-06-18 17:15:18 UTC (rev 10029)
+++ trunk/externals/mrpeach/net/udpreceive.c	2008-06-18 17:30:18 UTC (rev 10030)
@@ -29,7 +29,7 @@
 {
     t_object  x_obj;
     t_outlet  *x_msgout;
-	t_outlet  *x_addrout;
+    t_outlet  *x_addrout;
     int       x_connectsocket;
     t_atom    x_addrbytes[4];
     t_atom    x_msgoutbuf[MAX_UDP_RECEIVE];
@@ -46,14 +46,14 @@
     int                 i, read = 0;
     struct sockaddr_in  from;
     socklen_t           fromlen = sizeof(from);
-	long                addr;
+    long                addr;
 
-	read = recvfrom(sockfd, x->x_msginbuf, MAX_UDP_RECEIVE, 0, (struct sockaddr *)&from, &fromlen);
+    read = recvfrom(sockfd, x->x_msginbuf, MAX_UDP_RECEIVE, 0, (struct sockaddr *)&from, &fromlen);
 #ifdef DEBUG
     post("udpreceive_read: read %lu x->x_connectsocket = %d",
         read, x->x_connectsocket);
 #endif
-	/* get the sender's ip */
+    /* get the sender's ip */
     addr = ntohl(from.sin_addr.s_addr);
     x->x_addrbytes[0].a_w.w_float = (addr & 0xFF000000)>>24;
     x->x_addrbytes[1].a_w.w_float = (addr & 0x0FF0000)>>16;
@@ -61,7 +61,7 @@
     x->x_addrbytes[3].a_w.w_float = (addr & 0x0FF);
     outlet_list(x->x_addrout, &s_list, 4L, x->x_addrbytes);
 
-	if (read < 0)
+    if (read < 0)
     {
         sys_sockerror("udpreceive_read");
         sys_closesocket(x->x_connectsocket);
@@ -87,7 +87,7 @@
     int                sockfd, portno = fportno;
     int                intarg, i;
 
-	/* create a socket */
+    /* create a socket */
     sockfd = socket(AF_INET, SOCK_DGRAM, 0);
 #ifdef DEBUG
     post("udpreceive_new: socket %d port %d", sockfd, portno);
@@ -100,7 +100,8 @@
     server.sin_family = AF_INET;
     server.sin_addr.s_addr = INADDR_ANY;
 
-    /* ask OS to allow another Pd to repoen this port after we close it. */
+    /* enable delivery of all multicast or broadcast (but not unicast)
+    * UDP datagrams to all sockets bound to the same port */
     intarg = 1;
     if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
         (char *)&intarg, sizeof(intarg)) < 0)
@@ -113,7 +114,7 @@
     if (bind(sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
     {
         sys_sockerror("udpreceive: bind");
-    	sys_closesocket(sockfd);
+        sys_closesocket(sockfd);
         return (0);
     }
     x = (t_udpreceive *)pd_new(udpreceive_class);
@@ -123,10 +124,10 @@
 
     /* convert the bytes in the buffer to floats in a list */
     for (i = 0; i < MAX_UDP_RECEIVE; ++i)
-	{
-		x->x_msgoutbuf[i].a_type = A_FLOAT;
-		x->x_msgoutbuf[i].a_w.w_float = 0;
-	}
+    {
+        x->x_msgoutbuf[i].a_type = A_FLOAT;
+        x->x_msgoutbuf[i].a_w.w_float = 0;
+    }
     for (i = 0; i < 4; ++i)
     {
         x->x_addrbytes[i].a_type = A_FLOAT;
@@ -152,5 +153,4 @@
         sizeof(t_udpreceive), CLASS_NOINLET, A_DEFFLOAT, 0);
 }
 
-/* end x_net_udpreceive.c */
-
+/* end udpreceive.c */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list