Oh, well I guess I'll finish up writing the book on this one myself ... More anon. guy keren wrote: > On Thu, 24 Feb 2000, Daniel Feiglin wrote: > > > I'm still rather mysified by it .... > > i'd say - just write the code as you understand it, and play with it a > little. > > the major difference with selecting for read() and selecting for write() > is - when to do this. > > when you select for read(), you place the file descriptor inside the > select loop all the time, because you want to be notified as soon as > there's input waiting to be read. when you select for write - you place > the file descriptor in the select loop only when you've got something to > write to that specific socket. select will tell you that this file > descriptor is active for writing, whenever there is space (in your LOCAL > system's socket buffer) to write data. > > a "real" server whose main loop is based on select() (or poll()) would use > this feature in one of two methods: > > 1. use a select() call with a '0' timeout before trying to write to a > socket. if the select call does not indicate that this file descriptor > is active, the file descriptor is added to the server's main select set > of write FDs. after empting that socket's write queue, it's removed > from the write set. > > 2. similar to the above, but including setting the socket to work in > non-blocking mode. this is done because even if select() shows that a > file descriptor's buffer has free space - there is no indication as to > how much free space there is, and thus, a write() onto that file > descriptor may still get blocked. > > now, i'd say - go and play with this for a bit, and keep your eyes on > steven's book while doing that, to check how to deal with the various > kinds of error conditions that might arise here. > > guy > > "For world domination - press 1, > or dial 0, and please hold, for the creator." -- nob o. dy
begin:vcard n:Feiglin;Daniel tel;cell:972 53 869986 tel;fax:972 9 862 1052 tel;home:972 9 832 0939 tel;work:972 9 861 6204 x-mozilla-html:FALSE org:Dilog Computers Ltd. adr:;;POB 36;Shavei Shomron, Mobile Post;;44858;ISRAEL version:2.1 email;internet:[EMAIL PROTECTED] x-mozilla-cpt:;-20112 fn:Daniel Feiglin end:vcard