home *** CD-ROM | disk | FTP | other *** search
- This package provides a quick-and-easy means of providing reliable
- and large-packet communication between processes.
-
- It is especially nice because initport() does all the hard work of
- initializing TCP connections, and select_server_stream() does the
- hard work of connecting processes to each other.
-
- To install, type
-
- make install
-
- To test, type
-
- make test
- reader
- writer (in different window)
- writer (in yet another window)
- writer (in yet ...)
- and so on.
-
-
- reader and writer are two programs that should communicate with
- each other. Type things into any of the writers and reader will
- print it out prefaced by the file descriptor the data came in on.
-
- Bugs and problems to Don Libes
- National Bureau of Standards
- Bldg 220, Rm A-127
- Gaithersburg, MD 20899
- (301) 975-3535
-
-
- SYNOPSIS
-
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <inet.h>
-
- cc [options] [files] sized_io.o stream.o
-
- DESCRIPTION
-
- This package implements packet or stream IO between a server process and
- a number of client processes, using the TCP/IP (stream) facilities.
-
- A client uses the call:
-
- s = initport(PORT_NUMBER(XXX),CLIENT,SOCK_STREAM);
-
- s is the server's data socket and is used as a file descriptor in further
- communication. The port may be specified by name (PORT_NAME("foo")), if it
- is registered.
-
- Similarly, the server uses the following call:
-
- s = initport(PORT_NUMBER(XXX),SERVER,SOCK_STREAM);
-
- s is the server's connection socket. To receive data or connections, the
- server calls select_server_stream().
-
- client = select_server_stream(s,&fds);
-
- This returns a file descriptor corresponding to a client, when a client has
- sent a message to the server. It handles initial connections as well as
- client deaths. s is the server's connection socket that was returned by
- initport(). fds is an int used by select...() for storing a bit string
- corresponding to client sockets. Initialize it to 0, and don't mess with it
- after that.
-
- To use the file descriptors in a stream-oriented manner, use read() and
- write(). To use the file descriptors in a packet-oriented manner, use
- sized_read() and sized_write(). The sized...() calls read and write one
- packet at a time, while packet boundaries are ignored in read() and write().
-
- cc = sized_read(fd,buffer,maxsize)
- cc = sized_write(fd,buffer,size)
-
- The arguments for sized_read() and sized_write() are very similar to read()
- and write(). The only difference is that in sized_read(), maxsize is the
- maximum size of an acceptable packet.
-