In my program, there is a thread blocking on a listen socket, which waits for other connections, and the code likes this:
{
......
FD_ZERO(&fd_sets);
FD_SET(sock_fd, &fd_sets);
ret_val = select(sock_fd + 1, &fd_sets, NULL, NULL, NULL);
if (ret_val > 0)
{
accept(sock_fd, NULL, NULL);
......
}
else
{
......
}
Per my understandings, if in other thread, shutdown the socket, and the code likes this:
{
......
shutdown(sock_fd, SHUT_RD);
......
}
I think the select() in the previous thread should return. But after testing, I find the select() is still in blocking.
Why shutdown a socket can't let the select() return?