I'm trying to figure out the best way to have only one incoming TCP
connection active at a time.
I inherited some code that calls tcp_close() on the listening pcb inside
the tcp_accept callback, and creates a new listener later when the
active connection is closed. I'm not certain that this is the best way
to do this, and suspect there may be edge cases that will be missed. The
listener has to set the SOF_REUSEADDR option whenever it gets created to
make everything work.
I've been trying to familiarize myself with lwip and looking to see if
there's a supported way to achieve this functionality. Some other
options that occur to me are using TCP_LISTEN_BACKLOG or calling
tcp_abort on all of the new pcbs inside the tcp_accept callback.
Does anyone have any advice for the best way to achieve only one active
connection at a time?