Skip to content

Instantly share code, notes, and snippets.

@d-a-v
Last active January 1, 2024 09:22
Show Gist options
  • Save d-a-v/ed67f7a6f476a043d1c7f347c829087e to your computer and use it in GitHub Desktop.
Save d-a-v/ed67f7a6f476a043d1c7f347c829087e to your computer and use it in GitHub Desktop.
portable way to clear tcp pcb in time-wait (esp8266/Arduino) - tcpCleanup() fix for lwip2
// https://github.com/esp8266/Arduino/issues/1923
// https://github.com/esp8266/Arduino/issues/4213
// compatible with lwip-v1 and -v2
// no need for #include
struct tcp_pcb;
extern struct tcp_pcb* tcp_tw_pcbs;
extern "C" void tcp_abort (struct tcp_pcb* pcb);
void tcpCleanup ()
{
while (tcp_tw_pcbs != NULL)
{
tcp_abort(tcp_tw_pcbs);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment