dupuy@amsterdam.columbia.edu (Alexander Dupuy) (11/26/86)
In article <46@otc.OZ> adjg@otc.OZ (Andrew Gollan) writes: >I need to have a server that forms a junction between two client >processes. Further if one of the clients is not present the other must >still be serviced. I read the manual on accept(2) and found that one >could use select(2) to wait for incoming connections. >... > if (select(2, &mask, (int *)0, (int *)0, 0) < 0) >... >The problem: > The select in the server never returns. >... >The questions: > Am I doing something horribly wrong or is it that select(2) > does not perform as documented? Have I missed something in the > documentation? The answer: Select(2) does perform as documented. You missed the note which describes the timeout (last) argument to select. "If timeout is a zero pointer the select blocks indefinitely. To effect a poll, the timeout argument should be non-zero, pointing to a zero valued timeval structure." You want to "effect a poll" like this: struct timeval poll = { 0, 0 }; if (select(2, &mask, (int *) 0, (int *)0, &poll) < 0) perror ("etc... @alex ---- arpa: dupuy@columbia.edu uucp: ...!seismo!columbia!dupuy