Socket listen doesn't unbind in C++ under linux

后端 未结 3 831
自闭症患者
自闭症患者 2021-01-11 17:12

I have a socket that listens on some port. I send the SIGSTOP signal to the thread that waits on the port (using accept) and terminate it. then I close the fd of the socket

3条回答
  •  长发绾君心
    2021-01-11 17:26

    I think the problem is that you have not properly closed the socket and/or your program.The socket probably still exists in the OS. check it with something like nestat -an. You should also check if your process has exited. If it has correctly ended, it should have closed your socket.

    What you should do is :

    • interrupt your thread with a signal.
    • when interrupted your thread should cleanly close the socket before the end.
    • then you can cleanly exit from your program.

    my2cents,

提交回复
热议问题