difference between “address in use” with bind() in Windows and on Linux - errno=98

前端 未结 1 1890
不知归路
不知归路 2020-12-20 06:31

I have a small TCP server that listens on a port. While debugging it\'s common for me to CTRL-C the server in order to kill the process.

On Windows I\'m able to res

1条回答
  •  借酒劲吻你
    2020-12-20 06:47

    You want to use the SO_REUSEADDR option on the socket on Linux. The relevant manpage is socket(7). Here's an example of its usage. This question explains what happens.

    Here's a duplicate of this answer.

    On Linux, SO_REUSEADDR allows you to bind to an address unless an active connection is present. On Windows this is the default behaviour. On Windows, SO_REUSEADDR allows you to additionally bind multiple sockets to the same addresses. See here and here for more.

    0 讨论(0)
提交回复
热议问题