Attached fixes (version 0.42.5 pd-extended):

out-of-order output on tcpserver.c

provides output of IP and socket on disconnect so if one maintains a
database of what client is associated with what socket (e.g. through a
coll), this way it reports it in a way that such an external database
can be updated accordingly.

Attached patch is created using diff -u.

Best wishes,

Ico


--- tcpserver.c.old	2010-03-26 14:25:22.000000000 -0400
+++ tcpserver.c	2010-03-26 18:34:14.000000000 -0400
@@ -8,6 +8,10 @@
 /* Written by Olaf Matthes <olaf.matt...@gmx.de>                                */
 /* Get source at http://www.akustische-kunst.org/puredata/maxlib                */
 /*                                                                              */
+/* March 26 2010                                                                */
+/* Additional fixes and improvements by Ivica Ico Bukvic <i...@bukvic.net>       */
+/* for the purpose of L2Ork http://l2ork.music.vt.edu                           */
+/*                                                                              */
 /* This program is free software; you can redistribute it and/or                */
 /* modify it under the terms of the GNU General Public License                  */
 /* as published by the Free Software Foundation; either version 2               */
@@ -190,7 +194,7 @@
         {
             freebytes(x, sizeof(*x));
             x = NULL;
-            error("%s_socketreceiver: unable to allocate %d bytes", objName, INBUFSIZE);
+            error("%s_socketreceiver: unable to allocate %d bytes", objName, (int)INBUFSIZE);
         }
     }
     return (x);
@@ -401,7 +405,7 @@
 {
     char            *bp;
     size_t          sent = 0;
-    double          timebefore;
+    //double          timebefore;
     int             result;
     fd_set          wfds;
     struct timeval  timeout;
@@ -658,7 +662,7 @@
 {
     int     client = -1;
     float   buf_size = 0;
-    t_atom  output_atom[3];
+    //t_atom  output_atom[3];
 
     if(x->x_nconnections <= 0)
     {
@@ -724,6 +728,13 @@
         if(x->x_fd[i] == x->x_sock_fd)
         {
             x->x_nconnections--;
+		    x->x_addrbytes[0].a_w.w_float = (x->x_addr[i] & 0xFF000000)>>24;
+		    x->x_addrbytes[1].a_w.w_float = (x->x_addr[i] & 0x0FF0000)>>16;
+		    x->x_addrbytes[2].a_w.w_float = (x->x_addr[i] & 0x0FF00)>>8;
+		    x->x_addrbytes[3].a_w.w_float = (x->x_addr[i] & 0x0FF);
+		    outlet_list(x->x_addrout, &s_list, 4L, x->x_addrbytes);
+		    outlet_float(x->x_sockout, x->x_fd[i]);	/* the socket number */
+			outlet_float(x->x_connectout, x->x_nconnections);
             post("%s: \"%s\" removed from list of clients", objName, x->x_host[i]->s_name);
             x->x_host[i] = NULL;	/* delete entry */
             x->x_fd[i] = -1;
@@ -738,7 +749,6 @@
             }
         }
     }
-    outlet_float(x->x_connectout, x->x_nconnections);
 }
 
 static void tcpserver_connectpoll(t_tcpserver *x)
@@ -789,14 +799,14 @@
         }
         else post("%s_connectpoll: getsockopt returned %d\n", objName, errno);
 #endif
-        outlet_float(x->x_connectout, x->x_nconnections);
-        outlet_float(x->x_sockout, x->x_fd[i]);	/* the socket number */
         x->x_addr[i] = ntohl(incomer_address.sin_addr.s_addr);
         x->x_addrbytes[0].a_w.w_float = (x->x_addr[i] & 0xFF000000)>>24;
         x->x_addrbytes[1].a_w.w_float = (x->x_addr[i] & 0x0FF0000)>>16;
         x->x_addrbytes[2].a_w.w_float = (x->x_addr[i] & 0x0FF00)>>8;
         x->x_addrbytes[3].a_w.w_float = (x->x_addr[i] & 0x0FF);
         outlet_list(x->x_addrout, &s_list, 4L, x->x_addrbytes);
+        outlet_float(x->x_sockout, x->x_fd[i]);	/* the socket number */
+        outlet_float(x->x_connectout, x->x_nconnections);
     }
 }
 
_______________________________________________
Pd-dev mailing list
Pd-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev

Reply via email to