[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] Changed IP address during runtime but TCP PCB stuck tim
Re: [lwip-users] Changed IP address during runtime but TCP PCB stuck time wait state
Mon, 17 Dec 2018 11:00:13 +0100
Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3
Le 12/17/2018 à 4:39 AM, uaz a écrit :
I am doing a webserver that allows users to change device ip address during
runtime (no power reset required).
I've tried 2 ways of doing so:
2. netif_remove() and then netif_add() a new interface with the new ip
In both methods, I will re-init my http server:
3. Create a new netconn: netconn_new()
4. Bind to http port: netconn_bind()
Unfortunately, netconn_bind() to port 80 will fail because apparently the
previous pcb bound to port 80 is still there, in time wait state (lwip will
not allow multiple sockets listening to the same port).
How do I make sure the previous pcb is completely deleted or freed?
Apparently you need to do something like :
#define SO_REUSE to 1 in your lwipopt.h
In your application do a
ip_set_option([yournetconn]->pcb.ip_pcb,SOF_REUSEADDR) to your new
netconn struct before doing the netconn_bind()
This allows binding to a addr/port that is already in use by a PCB in
TIME WAIT state.
That's what I could find looking at the source (that's not really
Description: Signature cryptographique S/MIME