lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Problem re-opening listening pbc


From: Keith Rubow
Subject: [lwip-users] Problem re-opening listening pbc
Date: Wed, 9 May 2018 13:11:49 -0700
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

I'm using LWIP for the first time (2.0.3, NO_SYS=1, callback API). Mostly things are going well. But I have an issue with allowing only a single TCP connection to a port. I open a listening pcb with tcp_new(), tcp_bind(), tcp_listen() and set an accept callback. In the accept callback I set up a receive callback, and I use tcp_close() to close the listening pcb. This causes any further connection attempts on the port to be refused. This works great.

However, the problem is when the connection I accepted is closed. My receive callback is called with p=NULL, so I then remove all the callbacks and close the active connection with tcp_close(). Then I re-open the listening pcb with tcp_new(), tcp_bind(), and tcp_listen(). HOWEVER, the tcp_bind() fails with ERR_USE, presumably because the pcb for the active connection is not fully closed yet, making the port still in use.

I found I can "fix" the problem by closing the active connection with tcp_abort() instead of tcp_close(), but this seems kind of wrong. If I knew when the pcb for the active connection was really fully closed, I could open the listening pcb then. But I don't see any way to tell when the close is finished. There is no callback for it, and I am not permitted to access the pcb after calling tcp_close().

So how can I re-open a listening pcb on the port after a connection is closed?

Keith Rubow



reply via email to

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