Attached fixes (version 0.42.5 pd-extended): lack of reporting of disconnect through the right outlet and added safer way of reporting disconnect as it can be triggered by out-of-order events. (there is still the issue of netserver not reporting socket info or ip address properly)
Attached patch is created using diff -u. Best wishes, Ico
--- netclient.c 2009-05-16 15:49:36.000000000 -0400 +++ ../../../../../pd-extended-svn-0.42.5/0.42/externals/maxlib/src/netclient.c 2010-03-26 18:36:18.000000000 -0400 @@ -3,7 +3,11 @@ /* Extended 'netsend', connects to 'netserver'. */ /* Uses child thread to connect to server. Thus needs pd0.35-test17 or later. */ /* Written by Olaf Matthes (olaf.matt...@gmx.de) */ -/* Get source at http://www.akustische-kunst.org/puredata/maxlib/ */ +/* 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 */ @@ -76,12 +80,14 @@ static void netclient_rcv(t_netclient *x); - /* get's called when connection has been made */ + /* get's called when connection status has changed */ static void netclient_tick(t_netclient *x) { - outlet_float(x->x_outconnect, 1); - /* add pollfunction for checking for input */ - sys_addpollfn(x->x_fd, (t_fdpollfn)netclient_rcv, x); + outlet_float(x->x_outconnect, x->x_connectstate); + /* add pollfunction for checking for input */ + if (x->x_connectstate == 1) { + sys_addpollfn(x->x_fd, (t_fdpollfn)netclient_rcv, x); + } } static void *netclient_child_connect(void *w) @@ -154,11 +160,12 @@ { if (x->x_fd >= 0) { - sys_rmpollfn(x->x_fd); + sys_rmpollfn(x->x_fd); sys_closesocket(x->x_fd); x->x_fd = -1; x->x_connectstate = 0; - outlet_float(x->x_outconnect, 0); + //outlet_float(x->x_outconnect, 0); + clock_delay(x->x_clock, 0); } } @@ -261,7 +268,8 @@ if(ret < 0) { error("netclient: can not read from socket"); - sys_closesocket(fd); + //sys_closesocket(fd); + netclient_disconnect(x); return; } if(FD_ISSET(fd, &readset) || FD_ISSET(fd, &exceptset)) @@ -272,14 +280,18 @@ if (ret < 0) { sys_sockerror("recv"); - sys_rmpollfn(fd); - sys_closesocket(fd); + //sys_rmpollfn(fd); + //sys_closesocket(fd); + + netclient_disconnect(x); } else if (ret == 0) { post("netclient: connection closed on socket %d", fd); - sys_rmpollfn(fd); - sys_closesocket(fd); + //sys_rmpollfn(fd); + //sys_closesocket(fd); + + netclient_disconnect(x); } else {
_______________________________________________ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev