|
From: | Jens Nielsen |
Subject: | Re: [lwip-users] Problem re-opening listening pbc |
Date: | Sat, 12 May 2018 12:13:06 +0200 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
Your bind to the listening port number fails because the local port is already used by the active connections, you might get past that by setting SOF_REUSEADDR but I'm on thin ice now so maybe someone more into this can clarify...
BR /Jens On 2018-05-12 00:44, Keith Rubow wrote:
I tried the backlog feature (not very well documented). I put #define TCP_LISTEN_BACKLOG 1 in my lwipopts.h file. I changed tcp_listen() to tcp_listen_with_backlog(), passing it the maximum number of simultaneous connection I want. I added tcp_backlog_delayed() to my accept callback. I added tcp_backlog_accepted() before tcp_close() when the connection was closed in either the receive data callback (with p=NULL), or when my application times out the connection.This does limit the number of connections that can be opened simultaneously. However, once the limit is reached, additional connection attempts are not refused (which is what I would prefer), rather the connection attempts simply time out. Still, this might be better than my initial approach of aborting additional unwanted connections, which resulted in the connection opening, but immediately closing again.Still, the question remains why lwip will not allow binding to a port number that has no current listening pcb, but does have one or more open connections. I don't understand why this would cause a problem.Keith Rubow
[Prev in Thread] | Current Thread | [Next in Thread] |