Unblock recvfrom when socket is closed

前端 未结 5 1282
自闭症患者
自闭症患者 2020-12-07 01:44

Let\'s say I start a thread to receive on a port. The socket call will block on recvfrom. Then, somehow in another thread, I close the socket.

On Windows, this will

5条回答
  •  旧时难觅i
    2020-12-07 02:20

    Call shutdown(sock, SHUT_RDWR) on the socket, then wait for the thread to exit. (i.e. pthread_join).

    You would think that close() would unblock the recvfrom(), but it doesn't on linux.

提交回复
热议问题