Update of /cvsroot/pure-data/externals/mrpeach/net
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24455
Modified Files:
tcpserver.c
Log Message:
Closing socket should actually work now. Before it was just removing it from the list.
Index: tcpserver.c
===================================================================
RCS file: /cvsroot/pure-data/externals/mrpeach/net/tcpserver.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** tcpserver.c 2 Aug 2007 15:56:10 -0000 1.7
--- tcpserver.c 6 Aug 2007 22:18:12 -0000 1.8
***************
*** 105,108 ****
--- 105,109 ----
static void tcp_server_send_bytes(int sockfd, t_tcpserver *x, int argc, t_atom *argv);
static void tcpserver_client_send(t_tcpserver *x, t_symbol *s, int argc, t_atom *argv);
+ static void tcpserver_disconnect(t_tcpserver *x);
static void tcpserver_client_disconnect(t_tcpserver *x, t_floatarg fclient);
static void tcpserver_socket_disconnect(t_tcpserver *x, t_floatarg fsocket);
***************
*** 407,410 ****
--- 408,435 ----
}
+ /* disconnect the client at x_sock_fd */
+ static void tcpserver_disconnect(t_tcpserver *x)
+ {
+ int i, fd;
+ t_tcpserver_socketreceiver *y;
+
+ if (x->x_sock_fd >= 0)
+ {
+ /* find the socketreceiver for this socket */
+ for(i = 0; i < x->x_nconnections; i++)
+ {
+ if(x->x_fd[i] == x->x_sock_fd)
+ {
+ y = x->x_sr[i];
+ fd = x->x_fd[i];
+ if (y->sr_notifier) (*y->sr_notifier)(x);
+ sys_rmpollfn(fd);
+ sys_closesocket(fd);
+ x->x_sock_fd = -1;
+ }
+ }
+ }
+ }
+
/* disconnect a client by socket */
static void tcpserver_socket_disconnect(t_tcpserver *x, t_floatarg fsocket)
***************
*** 418,425 ****
}
x->x_sock_fd = sock;
! tcpserver_notify(x);
}
-
/* disconnect a client by number */
static void tcpserver_client_disconnect(t_tcpserver *x, t_floatarg fclient)
--- 443,449 ----
}
x->x_sock_fd = sock;
! tcpserver_disconnect(x);
}
/* disconnect a client by number */
static void tcpserver_client_disconnect(t_tcpserver *x, t_floatarg fclient)
***************
*** 439,443 ****
--client;/* zero based index*/
x->x_sock_fd = x->x_fd[client];
! tcpserver_notify(x);
}
--- 463,467 ----
--client;/* zero based index*/
x->x_sock_fd = x->x_fd[client];
! tcpserver_disconnect(x);
}