<div dir="ltr">Hi Martin, <div><br></div><div>Thanks for your reply.</div><div><br></div><div>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.</div>


<div><br></div><div>But I experience another issue.</div><div style>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&#39;t bind to it.</div>

<div style>I have to wait until the end of TIME-OUT before restarting Pd.</div><div style>I found a solution [1] (restart network service) to release the socket, so that tcpserver can bind to the same port again.</div><div style>

But it could be good to handle this inside Pd isn&#39;t it ?</div><div style><br></div><div style>So I guess two ways : </div><div style>1- according to WMR in [1], we can set SO_REUSEADDR via setsockopt(2), but I don&#39;t know if this possible without lots of code rewriting...</div>

<div style>2- tcpserver could also have a [bind &lt;port_number&gt;( 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.</div>

<div style><br></div><div style>But I&#39;m not very familiar with sockets, so maybe I&#39;m wrong...</div><div style><br></div><div style>Cheers</div><div style><br></div><div style>Antoine </div><div style><br></div><div style>

<br></div><div style>[1] <a href="http://serverfault.com/questions/329845/how-to-forcibly-close-a-socket-in-time-wait">http://serverfault.com/questions/329845/how-to-forcibly-close-a-socket-in-time-wait</a></div></div><div class="gmail_extra">

<br clear="all"><div>--<br>do it yourself                       <br><a href="http://antoine.villeret.free.fr" target="_blank">http://antoine.villeret.free.fr</a><br></div>
<br><br><div class="gmail_quote">2013/5/19 Martin Peach <span dir="ltr">&lt;<a href="mailto:martin.peach@sympatico.ca" target="_blank">martin.peach@sympatico.ca</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Yes, it seems that the routine that adds new connections doesn&#39;t check to see if it has passed the number of connection slots.<br>
There are MAX_CONNECT slots allocated when [tcpserver] starts.<br>
<br>
Thanks for finding this bug!<br>
<br>
There is no reason to limit the number of connections to 32 except to not use up memory.<br>
I think it could be changed to either dynamically add space for new connections without limit or set MAX_CONNECT with a creation argument.<br>
<br>
For now you could recompile it with MAX_CONNECT set to another value. (At some point the OS will run out of sockets. Before that Pd will slow down...)<br>
<br>
#define MAX_CONNECT 10000<br>
<br>
<br>
Martin<div class="im"><br>
<br>
On 2013-05-18 17:37, Antoine Villeret wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
so I reply to myself...<br>
<br>
I found this in the code of both tcpserver.c :<br>
#define MAX_CONNECT 32 /* maximum number of connections */<br>
<br>
which could be an answer embryo<br>
<br>
so, I shouldn&#39;t make more than 32 connections on the same tcpserver, ok,<br>
but why ?<br>
is there a good reason to fix this to 32 ?<br>
<br>
and this doesn&#39;t tell me why it crashes...<br>
reaching the MAX_CONNECT should handles in the code isn&#39;t it ?<br>
<br>
cheers<br>
<br>
a<br>
<br>
--<br>
do it yourself<br>
<a href="http://antoine.villeret.free.fr" target="_blank">http://antoine.villeret.free.<u></u>fr</a><br>
<br>
<br>
2013/5/16 Antoine Villeret &lt;<a href="mailto:antoine.villeret@gmail.com" target="_blank">antoine.villeret@gmail.com</a><br></div>
&lt;mailto:<a href="mailto:antoine.villeret@gmail.com" target="_blank">antoine.villeret@<u></u>gmail.com</a>&gt;&gt;<div><div class="h5"><br>
<br>
    hi all,<br>
<br>
    I&#39;ve just notice [tcpserver] crashes when the 34th client try to connect<br>
    both iemnet and mrpeach are affected<br>
<br>
    iemnet version send a strange number on the 33th connection<br>
    (like 2.8686e+07) and crashes on the 34th<br>
<br>
<br>
    here is a gdb output for iem :<br>
    Program received signal SIGSEGV, Segmentation fault.<br>
    0x00007fffcdbca746 in tcpserver_connectpoll (x=0x66994c0) at<br>
    tcpserver.c:503<br>
    503     x-&gt;x_sr[i] = y;<br>
    (gdb) watchdog: signaling pd...<br>
<br>
<br>
    and for mrpeach :<br>
    Program received signal SIGSEGV, Segmentation fault.<br>
    0x00007fffcddaf585 in tcpserver_connectpoll (x=0xadfc1c0) at<br>
    tcpserver.c:1113<br>
    1113       outlet_float(x-&gt;x_sockout, x-&gt;x_sr[i]-&gt;sr_fd);/* the<br>
    socket number */<br>
    (gdb) watchdog: signaling pd...<br>
<br>
<br>
    it happens on ubuntu 12.04 64 bit<br>
    pd 0.44.2<br>
    and SVN update today<br>
<br>
    i&#39;m certainly doing something wrong to get this (like keeping<br>
    clients connected all the time)<br>
    but a crash is never welcome...<br>
<br>
    cheers<br>
<br>
    antoine<br>
    --<br>
    do it yourself<br>
    <a href="http://antoine.villeret.free.fr" target="_blank">http://antoine.villeret.free.<u></u>fr</a><br>
<br>
<br>
<br>
<br></div></div>
______________________________<u></u>_________________<br>
<a href="mailto:Pd-list@iem.at" target="_blank">Pd-list@iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -&gt; <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/<u></u>listinfo/pd-list</a><br>
<br>
</blockquote>
<br>
</blockquote></div><br></div>