Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!spool.mu.edu!sdd.hp.com!caen!uflorida!atlantis.cis.ufl.edu!leh From: leh@atlantis.cis.ufl.edu (Les Hill) Newsgroups: comp.unix.programmer Subject: Re: IPC/socket QUESTION... Keywords: IPC, socket, accept(), blocking Message-ID: <26803@uflorida.cis.ufl.EDU> Date: 8 Feb 91 20:53:07 GMT References: <1991Feb8.150520.5678@en.ecn.purdue.edu> Sender: news@uflorida.cis.ufl.EDU Reply-To: leh@atlantis.cis.ufl.edu (Les Hill) Distribution: na Organization: U of Florida. Computer Science Dept. Lines: 23 In article <1991Feb8.150520.5678@en.ecn.purdue.edu>, hoff@en.ecn.purdue.edu (Michael Hoefflinger) writes: |> --> The question is how do I make this accept() call NON-BLOCKING? In |> other words, if there are no clients waiting to connect, I would |> like accept() to return with errno=EWOULDBLOCK instead of blocking |> until someone wants to connect. |> Michael Hoefflinger |> uxg@fugue.cc.purdue.edu (NeXT) --> The answer is to use fcntl() (or perhaps ioctl() on your machine) and set the socket's descriptor to non-blocking. Under SunOS4.1.1 I would do either rc = fcntl(socket,F_SETFL,O_NDELAY); or rc = fcntl(socket,F_SETFL,FNDELAY); both of which will do the Right Thing (tm). Les Hill -- Extraordinary crimes against the people and the state have to be avenged by agents extraordinary. Two such people are John Steed -- top professional, and his partner, Emma Peel -- talented amateur; otherwise known as "The Avengers." UUCP: ...!gatech!uflorida!leh BITNET: vishnu@UFPINE INTERNET: leh@ufl.edu