C socket blocking call

Viewed 3832

I wonder about the behaviour of socket on blocking and nonblocking actions. What happens to threads blocking on socket when the socket blocking mode changes ? Here is the scenario; thread1(T1) creates a UDP socket and

fd = socket(AF_INET , SOCK_DGRAM, 0);

T1 waiting(sleeping) for receive

recv(fd, buf , sizeof(buf) , 0);

and thread2(T2) changes socket mode to non-blocking before socket receive any data

fcntl(fd, F_SETFL, O_NONBLOCK);

what happens to T1 ? Is it signalled/waked because the socket is no more blocking ?

4 Answers
Related