On 2013-05-20 08:19, Antoine Villeret wrote:
Hi Martin,

Thanks for your reply.

For now, I increase the MAX_CONNECT value and I also make each client
disconnecting after they receive expected data, and they connect again
if needed.

But I experience another issue.
If Pd crashes for any reason, the socket stay in a TIME_WAIT state and
if Pd restarts asap, the port may not be available and thus tcpserver
can't bind to it.
I have to wait until the end of TIME-OUT before restarting Pd.
I found a solution [1] (restart network service) to release the socket,
so that tcpserver can bind to the same port again.
But it could be good to handle this inside Pd isn't it ?

So I guess two ways :
1- according to WMR in [1], we can set SO_REUSEADDR via setsockopt(2),
but I don't know if this possible without lots of code rewriting...

[mrpeach/tcpserver] already does this. If the socket is in some other state than TIME_WAIT it will still block. There is more than one version of [tcpserver] around. In Pd-extended there is [net/tcpserver], [iemnet/tcpserver] and [mrpeach/tcpserver].


2- tcpserver could also have a [bind <port_number>( message to select
the port to bind to and send out error through its right outlet to
notice if port is available or not, so that we can try to bind again
until a port is available.

Yes, I could add that.

Martin

_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
http://lists.puredata.info/listinfo/pd-list

Reply via email to