Article View: comp.sys.transputer
Article #90Polling Helios Connected Sockets
From: droux
Date: Tue, 04 Aug 1992 11:13
Date: Tue, 04 Aug 1992 11:13
40 lines
1959 bytes
1959 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. ioctl allows us to set the socket associated with the descriptor to blocking or not blocking, because we offer both possibilies. For example: ioctl(fd, FIONBIO, "\0"); to set the socket blocking or ioctl(fd, FIONBIO, "\1"); to set it non-blocking, and recv(fd, buffer, 1, MSG_PEEK) to poll it. We have developed this method for 4.3BSD (on NeXT) and System V (on Sun) and it works fine. Now we are porting this on a different Unix like operating system (Perihelion Helios) which does not provide the ioctl system call. A replacement of it is the POSIX fcntl() command. This function takes a command and a flag argument to set some of the file options. One of these flags is O_NONBLOCK option which will cause future calls to recv or read to return immediately even there is no data available. Our problem is: HOW TO SET THE SOCKET TO BLOCKING AND NONBLOCKING ? To set it to nonblocking, we presume that the command would be fcntl(fd, F_SETFL, O_NONBLOCK); But what is the reverse operation ? All suggestions are welcome ! Thank you for your attention. Daniel Liebhart & Nicolas Droux. E-mail: droux@hei.unige.ch, University of Geneva, Switzerland.
Technical Details
Message-ID:
<1992Aug4.131335.1@hei.unige.ch>Path:
arc1-ca.pugleaf.net!sparky!uunet!gatech!darwin.sura.net!Sirius.dfn.de!chx400!ugun2b!hei.unige.ch!drouxShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!darwin.sura.net!Sirius.dfn.de!chx400!ugun2b!hei.unige.ch!droux Newsgroups: comp.sys.transputer Subject: Polling Helios Connected Sockets Message-ID: <1992Aug4.131335.1@hei.unige.ch> From: droux@hei.unige.ch Date: 4 Aug 92 13:13:35 +0200 Organization: University of Geneva, Switzerland Nntp-Posting-Host: ugheia Nntp-Posting-User: droux Lines: 41