I'm working on a network project (sockets). I have read some article like link>> and link>> but I can't understand them very well. I want to handle operations server-side and I should understand them. Now I think the readfds is handles the incoming data operation (Am I right? I don't know) and the writefds is handles the outgoing data (with send() method) operation (Am I right? I don't know). And the last one; the exceptfds is handles the socket exceptions like disconnection/close operation (Am I right? I don't know). These are only my quesses, I don't know anything about them (without a article description) and I want to ask them in here to understand. Can anybody help me about this? I'll implement a I/O system server-side (high-performance) and I need to understand them very much! Thanks...
Asked
Active
Viewed 244 times
0
-
1You got *readfds* and *writefds* right. Link to [an explanation of *exceptfds*](http://stackoverflow.com/a/1343995/315052). Also, `select()` is probably not your best choice for a high-performance system. Consider `epoll` (on Linux) or `kqueue` (on bsd) instead. Even `poll()` would probably do a little better than `select()`. – jxh Jun 26 '13 at 18:08
1 Answers
2
In the most general sense, select() is a way of having your application wait until something interesting happens. This interesting event can be:
Data is available on one of the sockets you listed in
readfds, so attempting toread()from that socket will not block.Write room becomes available on one of the sockets you listed in
writefds, so attempting towrite()to that socket will not block.Something unusual (like out-of-band data being received) happens on one of the sockets you listed in
exceptfds.The amount of time you specified in
timeouthas passed, but nothing else has happened.
-
What do you think about high-performance sockets? Is select() method is suitable for it? What else? – Mehmet Fatih Marabaoğlu Jun 26 '13 at 18:19
-
There are some techniques (e.g, AIO, `epoll()`, and `kqueue()`) which can end up performing slightly better under very high concurrency, but you are unlikely to ever need them. If you're really interested, though, you may want to check out [libev](http://software.schmorp.de/pkg/libev.html), which abstracts away some of the platform-specific nastiness. – Jun 26 '13 at 18:34