I'm trying to accept a socket non-blockingly:
accept4(s, (struct sockaddr *) &peerAddress, &len,SOCK_NONBLOCK);
where as s is a fd, peerAddres is an address, and len, is its length. I wish that accept won't block the thread. Though, once I debug, the process is stuck at this line, while no connection is pending. What is my mistake?
SOCK_NONBLOCK just sets the newly accepted socket to non-blocking. It does not make accept itself non-blocking. For this one would need to set the listen socket non-blocking before calling accept.
SOCK_NONBLOCK
accept
2.1m questions
2.1m answers
60 comments
57.0k users