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