IPC/socket QUESTION...

Les Hill leh at atlantis.cis.ufl.edu
Sat Feb 9 07:53:07 AEST 1991


In article <1991Feb8.150520.5678 at en.ecn.purdue.edu>, hoff at 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 at 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 at UFPINE    INTERNET: leh at ufl.edu



More information about the Comp.unix.programmer mailing list