Is there a way to find out if a socket is already in Non-Blocking mode in Windows?
I know this can be done in case of Linux, but, I am unable to find any way for this Windows.
All my coding is in ‘C’ language. Is there a way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only way you can check this is by doing something illegal on a nonblocking socket and checking that it fails in an expected way. Hardly the most robust design.
The socket will be blocking unless you explicitly set it nonblocking using WSAIoctl or ioctlsocket with
FIONBIO. That cannot be too hard to check in your code, I would have thought. If you have to track this at runtime, a flag per socket as suggested by @jweyrich is the way to go.