[PD-dev] mrpeach/tcpserver question

Ivica Ico Bukvic ico at vt.edu
Sat May 1 16:55:15 CEST 2010


Martin,

Just tried the latest version and the problem with stuck port persists,
suggesting that either Ubuntu is doing something funny or that the
destructor is to blame.

A simple test to perform is to use attached test patch:

1) Connect the client
2) Close the patch without explicitly disconnecting the client
3) Reopen the patch and the tcpserver will fail to be created until the
timeout has taken place (on my machine 60 seconds)

Console output in this case is:

tcpserver listening on port 9999
tcpclient 2010 Martin Peach-style
tcpclient: connecting socket 8 to port 9999
tcpserver: accepted connection from 127.0.0.1 on socket 9
tcp_server_free...
...tcp_server_free
tcpclient_free...
tcpclient: disconnected
...tcpclient_free

However, if one explicitly disconnects before closing the patch, that
works just fine:

tcpserver listening on port 9999
tcpclient 2010 Martin Peach-style
tcpclient: connecting socket 8 to port 9999
tcpserver: accepted connection from 127.0.0.1 on socket 9
tcpclient: disconnected
tcpserver: connection closed on socket 9
tcpserver: "127.0.0.1" removed from list of clients
tcp_server_free...
...tcp_server_free
tcpclient_free...
tcpclient: not connected
...tcpclient_free

Notice how in the first case there is never a "disconnect" taking place.
Hence the problem.

In production environment it would be silly to require everyone to
explicitly disconnect when closing the patch. IMO these things should
happen automagically when closing the patch.

Best wishes,

Ico

-------------- next part --------------
#N canvas 376 215 450 300 10;
#X declare -lib mrpeach;
#X obj 146 -21 import mrpeach;
#X obj 155 35 tcpserver 9999;
#X floatatom 158 74 5 0 0 0 - - -;
#X obj 245 195 tcpclient;
#X msg 252 164 connect 127.0.0.1 9999;
#X msg 229 137 disconnect;
#X connect 1 1 2 0;
#X connect 4 0 3 0;
#X connect 5 0 3 0;


More information about the Pd-dev mailing list