Can a socket be made non-blocking only for the recv() function?
12,866
For windows, you can use ioctlsocket()
to set the socket in non-blocking mode. Unfortunately these settings apply to all operations on the socket. So for your case you'll have to switch it between the receivings and the sendings.
For the records:
For linux, you could have used the MSG_DONTWAIT
flag in the recv()
call arguments. The single call will then be non blocking.
Related videos on Youtube
Author by
alk
Be thoughtful and attentive ... - but just do it! #SOreadytohelp
Updated on September 15, 2022Comments
-
alk over 1 year
I want to be able to call
recv()
without having to block, so I want to make it non-blocking, but I do not want it to be non blocking when sending data. So can a socket be made non-blocking only for therecv()
function, or does the blocking/non-blocking mode affects all of the socket functions?-
vpalmu about 9 yearsYes but last I checked recv() won't block if there's even 1 byte of data.
-