简体   繁体   中英

What is SOCKET accept() error errno 316?

On OSX I keep getting a socket error of 316 after calling accept() on a bound & listening socket. I get a valid socket returned, and I believe I then use it fine, (though I may not be, I need to double check this, as I am accepting hundreds of connections at any moment) but errno has been set.

I'm trying to understand the documentation on the unix accept(2) man pages which notes (which, incidentally, is missing from apple's accept() documentation )

Linux accept() (and accept4()) passes already-pending network errors on the new socket as an error code from accept(). This behavior differs from other BSD socket implementations. For reliable operation the application should detect the network errors defined for the protocol after accept() and treat them like EAGAIN by retrying.

now, 316 works out as 256 OR'd with ETIMEDOUT(60). So, I'm curious as to how I should be handling this;

  1. If ANY error is set after accept(), should I accept() again?
  2. Should I close() the SOCKET that accept DID return?
  3. Are the unix errno code's 8 bit? (all the codes I see are <128) and is this an erroneous bit set in memory, or is it a special flag, like a warning (I cannot find any documentation on the errno format's)
  4. Does this error mean the connection I just popped from the stack timed out... itself and the OS disconnected them, or wasn't accept()'d by me fast enough?

Do not examine errno unless accept() has returned -1. If accept() returns a valid file descriptor then the value of errno is undefined .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM