title: How to change socket's listening port after accept() was called?
body: <p>I'd like to change the port a socket is listening on. The problem is that I can't do it as long as a call to accept() is still in progress. I tried closing the socket expecting accept() to exit and return negative value. But it doesn't happen on FreeRTOS. When I close the socket from different thread accept() still executes. The only workaround I came up with is to set a flag in a variable, make a TCP connection and then when accept() finishes, check the flag, bind() with new port nad call listen(). But maybe there is a more elegant method?</p>