On Dec 28, 2016, at 06:45 AM, Daniel Pauli <[email protected]> wrote:


Am I understanding the description correctly that sending on the stale 
connection eventually blocks once the remote side has crashed and this prevents 
sending on the new socket (only because the thread is blocked)?



If so, then the socket buffer on the stale socket has filled up (most likely) 
and is now blocking.  This is blocking I/O operating as expected when data is 
not being acknowledged.  You should use non-blocking sockets and select if your 
server is servicing multiple sockets on a single thread.



Joel


Attempting to send on the stale socket blocks, which is okay on its own. But 
I'm already using select() and observed that
 
these stale sockets still somehow seem to block communication over new sockets,


If this is actually happening as described, that would be unexpected/faulty 
behavior.  One TCP socket in the half-open state should not have any effect on 
the other TCP connections.

 
even when no stale sockets are included in the write set of select().


I'm a little confused about the use of select in your application.  Are you 
using it with blocking sockets?  Select returning write-ability doesn't 
guarantee the send call won't block.  If you have a blocking socket and the 
size in the send call can't fit in the amount of available buffer space, the 
call will block

 
I even close() (successfully, according to the return value) those stale 
sockets after they failed to be write-ready after 10 seconds, but I can see in 
Wireshark that LWIP still sends retransmissions from the port number of the 
closed socket. 


Could it be that close() cannot send FIN because the output buffer is full, so 
the socket still remains active? Is there a way from the API to just drop the 
connection without involving any more communication?


Calling close() will initiate a graceful synchronized closure of the 
connection.  This means continuing to send any queued data until it is ACKed, 
the send times out, or we received a RST.  Then a FIN is sent indicating the 
sending pathway is closed.



Lastly, what version of LwIP are you using?


Joel
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to