Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!columbia!amsterdam.columbia.edu!dupuy From: dupuy@amsterdam.columbia.edu (Alexander Dupuy) Newsgroups: comp.unix.questions Subject: Re: Using select(2) to wait for connect(2) Message-ID: <3930@columbia.UUCP> Date: Tue, 25-Nov-86 22:07:49 EST Article-I.D.: columbia.3930 Posted: Tue Nov 25 22:07:49 1986 Date-Received: Wed, 26-Nov-86 00:14:14 EST References: <46@otc.OZ> Sender: nobody@columbia.UUCP Reply-To: dupuy@amsterdam.columbia.edu (Alexander Dupuy) Organization: Columbia University CS Department Lines: 34 Keywords: select sockets AF_UNIX 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