lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] TCP send() fails when other sockets perform retransmiss


From: Daniel Pauli
Subject: Re: [lwip-users] TCP send() fails when other sockets perform retransmissions
Date: Fri, 30 Dec 2016 17:43:14 +0100

I'm a little confused about the use of select in your application.  Are you using it with blocking sockets?

I tested with both blocking and non-blocking send. I observed that non-blocking send (MSG_DONTWAIT flag set) on sockets determined as write-ready by select() sometimes returned ENOMEM when "stale sockets" are around. After applying the patch from http://lwip.100.n7.nabble.com/bug-49684-lwip-netconn-do-writemore-non-blocking-ERR-MEM-treated-as-failure-td27860.html, I got EWOULDBLOCK errors instead.


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.

So there's no direct way for the application to tell LWIP to just give up on one socket without further trying to send data? Can the application specify a send timeout?

Lastly, what version of LwIP are you using?

I'm using 2.0.0 RC1


Daniel 


On Wed, Dec 28, 2016 at 4:23 PM, Joel Cunningham <address@hidden> wrote:


On Dec 28, 2016, at 06:45 AM, Daniel Pauli <address@hidden> 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
address@hidden
https://lists.nongnu.org/mailman/listinfo/lwip-users


reply via email to

[Prev in Thread] Current Thread [Next in Thread]