There is a Socket program that recently found a weird question: as a server side, after receiving the client connection, the error process exits when select, at this time, Errno is EBADF.
Code: // Set SELECT IO Multi-Work Waiting Time Select_time.tv_sec = 1; SELECT_TIME.TV_USEC = 0; // Set SELECT Error Waiting Time Sleeptime.tv_usec = 0; FD_ZERO (& RFDS); fd_set (port_fd , & rfds); Int nfds = port_fd 1; // I / O multiplexing, waiting for any descriptors to beready rc = SELECT (NFDS, & RFDS, NULL, NULL, & SELECT_TIME); if (rc == -1) {Switch (Errno) {CASE EBADF: // After the error, exit Break; Case Eintr: Continue; ... default: continue;}}
I haven't found the reason for a long time, it should be a SELECT problem, but SELECT is the system, shouldn't it be more stable? So I changed it as a POLL, and the problem is solved. After reviewing many information, the introduction is almost consistent. At this time, at this time, use the Select almost exactly the same. So, when SELECT has a problem, try a POLL.