Closing a listening TCP socket in C

前端 未结 1 840
情书的邮戳
情书的邮戳 2021-01-05 23:18

Suppose you have a socket listening on a TCP port, and some clients are connected. When one issues sock_close(fd) in C and tries to bind again on the same port, binding fail

相关标签:
1条回答
  • 2021-01-05 23:59

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

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