home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!utcsri!robinson
- Newsgroups: comp.protocols.tcp-ip
- From: robinson@mdivax1.uucp (Jim Robinson)
- Subject: Re: Should connect() block after setting NDELAY?
- Message-ID: <1992Nov10.221841.2325@mdivax1.uucp>
- Reply-To: robinson@mdd.comm.mot.com (Jim Robinson)
- Organization: Motorola - Mobile Data Division; Richmond, BC
- X-Newsreader: TIN [version 1.1 PL6]
- References: <dank.720994781@blacks>
- Date: 10 Nov 92 22:21:53 GMT
- Lines: 36
-
- Daniel R. Kegel (dank@blacks.jpl.nasa.gov) wrote:
- >
- >Hi all,
- >I'm writing an application that opens sockets to many servers in parallel
- >before sending out a query to each server (also in parallel). It sets
- >the sockets into nonblocking mode before the connect() as follows:
- > int flags;
- > #ifdef USE_FIONBIO
- > flags=1;
- > netioctl(qp->fds, FIONBIO, (char *)&flags);
- > #else
- > flags = fcntl(qp->fds, F_GETFL, 0);
- > #ifdef USE_O_NDELAY
- > flags |= O_NDELAY;
- > #else
- > flags |= FNDELAY;
- > #endif
- > fcntl(qp->fds, F_SETFL, &flags);
- > #endif
- >The problem is, under SunOS 4.1.1, connect() then blocks until a
- >accept, reject, or defer response comes back from the server.
- >This can take several seconds if the Internet is being slow.
- >The local Sun guy was able to see this in the source code, but does not
- >consider it a bug. What do you all think- is it reasonable for connect()
- >to block for several seconds when the socket is supposedly in nonblocking
- >mode?
-
- On a semi-related topic I can say that if, on SunOS 4.1.2, you set the
- socket to nonblocking with POSIX O_NONBLOCK, a subsequent connect() will
- indeed *block*; i.e., O_NONBLOCK has no effect on the connect().
-
- --
- Jim Robinson
- robinson@mdd.comm.mot.com
- {ubc-cs!van-bc,uunet}!mdivax1!robinson
-
-