Understanding select() function for implement

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...

Upvotes: 0

Views: 514

Answers (1)

user149341
user149341

Reputation:

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 to read() from that socket will not block.

  • Write room becomes available on one of the sockets you listed in writefds, so attempting to write() 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 timeout has passed, but nothing else has happened.

Upvotes: 2

Related Questions