This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

non-block recv is available in TCP sccket?

can recv  be set to non-block mode use setsockopt?

in my code ,I tried the following two methoded,but the recv both work in blocking mode

sock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);

1)

short  receiv_nonBlocking = 0;

setsockopt(sock, SOL_SOCKET, SOCKOPT_RECV_NONBLOCK  , &receiv_nonBlocking, sizeof(receiv_nonBlocking));

2) unsigned long  timeoutvalue = 0;

setsockopt(sock, SOL_SOCKET, SOCKOPT_RECV_TIMEOUT   , &timeoutvalue      , sizeof(timeoutvalue      ));

is there any wrong in my code above? why I can't set recv in non-blocking mode?