- 论坛徽章:
- 0
|
你看man select_tut有非常好的例子和说明。
用select一般不用NON BLOCKING socket.
Except as indicated in 7., the functions read(), recv(), write(), and send() never have a return value less
than 1 except if an error has occurred. For instance, a read() on a pipe where the other end has died returns
zero (so does an end-of-file error), but only returns zero once (a followup read or write will return -1).
Should any of these functions return 0 or -1, you should not pass that descriptor to select ever again. In
the above example, I close the descriptor immediately, and then set it to -1 to prevent it being included in
a set. |
|