home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / protocol / tcpip / 5120 < prev    next >
Encoding:
Internet Message Format  |  1992-11-10  |  1.7 KB

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