Article View: comp.unix.programmer
Article #337Re: Polling Sockets
From: Steven F. LeBrun
Date: Wed, 05 Aug 1992 11:43
Date: Wed, 05 Aug 1992 11:43
29 lines
1912 bytes
1912 bytes
>We are developing a distributed little system whichs communication >is based on the berkeley socket abstraction. >Now we are faced to the following problem: > >To poll from a given socket, that means to test if there is some >data arrived without reading it yet, we use the UNIX system call >ioctl to set the access mode to the socket and the function recv >to poll it. ... >Our problem is: HOW TO SET THE SOCKET TO >BLOCKING AND NONBLOCKING ? Have you tried the system call select()? This function allows you to determine if there is any I/O pending for a set of file descriptors. The last argument in select() is a pointer to a timeout value. If the timeout pointer is NULL, the call to select() blocks and a non-NULL timeout pointer allows you to poll. -- +--------------------------------------------------------------------------+ | Steven F. LeBrun | MIT Lincoln Laboratory, Group 91 | | | 244 Wood Street, Room LI-136 | | lebrun@ll.mit.edu (Internet) | Lexington, MA 02173-9108 | | lebruns@merlin (internal) | Phone:(617)-981-5742, FAX:(617)-981-0991 | +--------------------------------------------------------------------------+ | "I am not a number, I am a free man!" -- No. 6 | +--------------------------------------------------------------------------+
Technical Details
Message-ID:
<9208050743.PN25053@LL.MIT.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!news.bbn.com!micro-heart-of-gold.mit.edu!xn.ll.mit.edu!ll.mit.edu!lebrunReferences:
<1992Aug4.130703.1@hei.unige.ch>Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!usc!news.bbn.com!micro-heart-of-gold.mit.edu!xn.ll.mit.edu!ll.mit.edu!lebrun From: lebrun@ll.mit.edu (Steven F. LeBrun) Subject: Re: Polling Sockets In-Reply-To: droux@hei.unige.ch's message of 4 Aug 92 13:07:03 +0200 Message-ID: <9208050743.PN25053@LL.MIT.EDU> Sender: news@ll.mit.edu Organization: MIT Lincoln Laboratory, Lexington, MA References: <1992Aug4.130703.1@hei.unige.ch> Date: Wed, 5 Aug 92 07:43:51 -0400 Lines: 29