lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Bind fails after previous server-initiated connection c


From: Joel Cunningham
Subject: Re: [lwip-users] Bind fails after previous server-initiated connection close
Date: Fri, 09 Jun 2017 09:38:03 -0500

Hi,

This is normal BSD semantics of a TCP listener, use SO_REUSEADDR before calling 
bind to avoid the issue


Joel

> On Jun 8, 2017, at 4:18 PM, Ignacio García Pérez <address@hidden> wrote:
> 
> Hi All,
> 
> I'm writing a simple FTP server that needs to be started up and shut down 
> with relatively high frequency (say once per minute), so each time I must 
> create the listening PCB, bind, listen, accept, etc. The problem is that when 
> I close a client connection the PCB goes into the TIME-WAIT state and the 
> next bind operation will fail with ERR_USE.
> 
> Looking at the code I see that all TIME-WAIT PCB are kept in a list and this 
> list is checked for the requested port in the tcp_bind() function.
> 
> Of course eventually the PCB is purged (after 2 * TCP_MSL = 120s by default), 
> but  that does not solve the problem in my scenario (which I admit is 
> somewhat exotic).
> 
> Question:
> 
> 1- Is this behaviour expected?
> 
> 2- Is there any workaround?
> 
> If the purpose of keeping the PCB in TIME-WAIT is to prevent new connections 
> to/from the same host:port to be created, it doesn't make sense to check when 
> calling tcp_bind(), it would make more sense to check calling tcp_connect() 
> or when an incoming connection is initiated.
> _______________________________________________
> 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]