Commit 2f00c1d8 authored by Yury Popov's avatar Yury Popov Committed by Arnim Läuger
Browse files

TIME_WAIT sockets fixes (#1838)

* Enable SO_REUSEADDR for server TCP sockets

* Reduce TCP_MSL to 5 sec

* Add changes notice for future updates

* Move MSL change to lwipiots.h
parent 92599171
......@@ -899,6 +899,15 @@
#define TCP_TTL (IP_DEFAULT_TTL)
#endif
/**
* TCP_MSL: Maximum segment lifetime
* Override for <tcp_impl.h> file
* See https://github.com/nodemcu/nodemcu-firmware/issues/1836 for details
*/
#ifndef TCP_MSL
#define TCP_MSL 5000UL
#endif
/**
* TCP_MAXRTX: Maximum number of retransmissions of data segments.
*/
......@@ -1455,7 +1464,8 @@
* SO_REUSE==1: Enable SO_REUSEADDR option.
*/
#ifndef SO_REUSE
#define SO_REUSE 0
/* See https://github.com/nodemcu/nodemcu-firmware/issues/1836 for details */
#define SO_REUSE 1
#endif
/**
......
......@@ -386,6 +386,7 @@ int net_listen( lua_State *L ) {
ud->tcp_pcb = tcp_new();
if (!ud->tcp_pcb)
return luaL_error(L, "cannot allocate PCB");
ud->tcp_pcb->so_options |= SOF_REUSEADDR;
err = tcp_bind(ud->tcp_pcb, &addr, port);
if (err == ERR_OK) {
tcp_arg(ud->tcp_pcb, ud);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment