diff options
author | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2010-03-24 16:40:47 +0000 |
---|---|---|
committer | IOhannes m zmölnig <zmoelnig@users.sourceforge.net> | 2010-03-24 16:40:47 +0000 |
commit | a77528f82a9c7078eddca92ea84160895c115c1b (patch) | |
tree | 411eb77be99e253174b8c77ce0cb1374d77c9eec /tcpclient.c | |
parent | e2dc7d09e7ecedb2806cc636711f88a1f4c84647 (diff) |
check for validity before disconnecting (and invalidate pointers after)
svn path=/trunk/externals/iem/iemnet/; revision=13257
Diffstat (limited to 'tcpclient.c')
-rw-r--r-- | tcpclient.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tcpclient.c b/tcpclient.c index 5f6ff06..42fe2e0 100644 --- a/tcpclient.c +++ b/tcpclient.c @@ -143,9 +143,11 @@ static void tcpclient_tick(t_tcpclient *x) } +static void tcpclient_disconnect(t_tcpclient *x); static void tcpclient_connect(t_tcpclient *x, t_symbol *hostname, t_floatarg fportno) { + if(x->x_fd>=0)tcpclient_disconnect(x); /* we get hostname and port and pass them on to the child thread that establishes the connection */ x->x_hostname = hostname->s_name; @@ -158,11 +160,11 @@ static void tcpclient_connect(t_tcpclient *x, t_symbol *hostname, t_floatarg fpo static void tcpclient_disconnect(t_tcpclient *x) { - if(x->x_sender)iemnet__sender_destroy(x->x_sender); - if(x->x_receiver)iemnet__receiver_destroy(x->x_receiver); - if (x->x_fd >= 0) { + if(x->x_sender)iemnet__sender_destroy(x->x_sender); x->x_sender=NULL; + if(x->x_receiver)iemnet__receiver_destroy(x->x_receiver); x->x_receiver=NULL; + sys_closesocket(x->x_fd); x->x_fd = -1; x->x_connectstate = 0; |