home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / protocol / tcpip / ibmpc / 4966 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  3.6 KB

  1. Xref: sparky comp.protocols.tcp-ip.ibmpc:4966 comp.sys.mac.programmer:14785
  2. Newsgroups: comp.protocols.tcp-ip.ibmpc,comp.sys.mac.programmer
  3. Path: sparky!uunet!cs.utexas.edu!torn!watserv2.uwaterloo.ca!watserv1!steam.uwaterloo.ca!eengelke
  4. From: eengelke@steam.uwaterloo.ca (Erick Engelke)
  5. Subject: Re: tcp-ip library nonblocking I/O (Berkeley compatible)?
  6. Message-ID: <BtuyFK.Lpp@watserv1.uwaterloo.ca>
  7. Sender: news@watserv1.uwaterloo.ca
  8. Organization: University of Waterloo
  9. References: <1992Aug24.125112.14506@info.ucl.ac.be> <BtJy7I.HBL@watserv1.uwaterloo.ca> <dank.715232338@blacks>
  10. Date: Mon, 31 Aug 1992 17:11:43 GMT
  11. Lines: 70
  12.  
  13. dank@blacks.jpl.nasa.gov (Daniel R. Kegel) writes:
  14. >eengelke@sail.uwaterloo.ca (Erick Engelke) writes:
  15. >>I hate to tell you this, but even the nicest BSD emulation libraries
  16. >>lack a lot of the BSD feel...
  17. >>Novell LWP includes a nice BSD 4.2 Windows emulation library.  FTP is just
  18. >>offerring a new release, so I expect they added Windows support, ask
  19. >>at info@ftp.com.  B&W's otherwise attractive product is lacking BSD 4.2
  20. >>emulation in either DOS or Windows...
  21. >
  22. >Perhaps Erick or another TCP/IP guru can answer some related questions.
  23. >I want to port to the Mac and to MS-DOS (not neccesarily Windows) a Unix 
  24. >program which initiates several connections to TCP servers and uses 
  25. >nonblocking I/O to manage all the connections simultaneously.
  26. >
  27. >Questions:
  28. >1) Can select() or poll() be used with tcp/ip sockets to detect which of a
  29. >    set of sockets is ready for I/O?
  30.  
  31. Yes, with one exception.  I believe FTP's PC/TCP does not support the
  32. use of select to asynchronously detect the establishment of a connection
  33. on a listenning socket.  Someone will surely correct me if I'm wrong.
  34. Otherwise, all systems make select look pretty identical.  
  35.  
  36. You will have to vary the size of your passed arg pointer as different
  37. implementations use everything from 8bits, to 32 bits, to much larger 
  38. for the fds arguments.  Definately use the fd_set type and the
  39. FD_ZERO, FD_SET and other macros or face total portability problems.
  40.  
  41.  
  42. >
  43. >2) Can one use non-blocking I/O on a socket?    If so, how?
  44. >   In UNIX, one does the following:
  45. >
  46. >      fd = socket(hp->h_addrtype, SOCK_STREAM, 0);
  47. >      /* Use non-blocking I/O on this socket */
  48. > #if USE_FIONBIO      /* some unix systems use ioctl to set nonblocking...*/
  49. >      ioctl(fd, FIONBIO, (char *)&state);
  50. > #else              /* others use fcntl() */
  51. >      flags = fcntl(fd, F_GETFL, 0);
  52. >      flags |= FNDELAY;
  53. >      fcntl(fd, F_SETFL, &flags);
  54. > #endif
  55. >      /* Start connecting to the host.  May get EINPROGRESS. */
  56. >      err = connect(fd, (struct sockaddr *)&sin, sizeof(sin));
  57. >
  58. >   Will this work in any of the popular IBM-PC tcp/ip packages?
  59. >   (FYI, the answer for TGV's Multinet under VMS is a qualified yes.
  60. >    I'd also like to know the answer for MacTCP.)
  61.  
  62. I believe all or most PC implementations use the setsockopt() or
  63. similar function with FIONBIO flags.  The numeric value varies,
  64. as do the returned error messages.  You will have to look up the
  65. values and proceedure for each implementation.
  66.  
  67. The real killer for most server ports are the limited number of
  68. concurrent tcp connections most users configure,  and the lack of
  69. proper forking facilities - a DOS limitation.  
  70.  
  71. If you plan for this to work as a TSR, there are a lot of big sacrifices
  72. to make, and you would be best off to drop any thought of starting
  73. with UNIX code.
  74.  
  75. If the goal is to do X-Windows, disable the Nagle algorithm or whatever
  76. they call it in that particular version.
  77.  
  78. Erick
  79. -- 
  80. Erick Engelke                      Engineering Computing
  81.                          University of Waterloo
  82. Waterloo TCP Architect         erick@development.watstar.uwaterloo.ca
  83.