home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume14 / sharedmem / part01 / stream / README < prev    next >
Encoding:
Text File  |  1988-05-17  |  2.4 KB  |  81 lines

  1. This package provides a quick-and-easy means of providing reliable
  2. and large-packet communication between processes.
  3.  
  4. It is especially nice because initport() does all the hard work of
  5. initializing TCP connections, and select_server_stream() does the
  6. hard work of connecting processes to each other.
  7.  
  8. To install, type
  9.  
  10.     make install
  11.  
  12. To test, type
  13.  
  14.     make test
  15.     reader
  16.     writer    (in different window)
  17.     writer  (in yet another window)
  18.     writer  (in yet ...)
  19.     and so on.
  20.  
  21.  
  22. reader and writer are two programs that should communicate with
  23. each other.  Type things into any of the writers and reader will
  24. print it out prefaced by the file descriptor the data came in on.
  25.  
  26. Bugs and problems to Don Libes
  27. National Bureau of Standards
  28. Bldg 220, Rm A-127
  29. Gaithersburg, MD  20899
  30. (301) 975-3535
  31.  
  32.  
  33. SYNOPSIS
  34.  
  35. #include <sys/socket.h>
  36. #include <netinet/in.h>
  37. #include <inet.h>
  38.  
  39.     cc [options] [files] sized_io.o stream.o
  40.  
  41. DESCRIPTION
  42.  
  43. This package implements packet or stream IO between a server process and
  44. a number of client processes, using the TCP/IP (stream) facilities.
  45.  
  46. A client uses the call:
  47.  
  48.     s = initport(PORT_NUMBER(XXX),CLIENT,SOCK_STREAM);
  49.  
  50. s is the server's data socket and is used as a file descriptor in further
  51. communication.  The port may be specified by name (PORT_NAME("foo")), if it
  52. is registered.
  53.  
  54. Similarly, the server uses the following call:
  55.  
  56.     s = initport(PORT_NUMBER(XXX),SERVER,SOCK_STREAM);
  57.  
  58. s is the server's connection socket.  To receive data or connections, the
  59. server calls select_server_stream().
  60.  
  61.     client = select_server_stream(s,&fds);
  62.  
  63. This returns a file descriptor corresponding to a client, when a client has
  64. sent a message to the server.  It handles initial connections as well as
  65. client deaths.  s is the server's connection socket that was returned by
  66. initport().  fds is an int used by select...() for storing a bit string
  67. corresponding to client sockets.  Initialize it to 0, and don't mess with it
  68. after that.
  69.  
  70. To use the file descriptors in a stream-oriented manner, use read() and
  71. write().  To use the file descriptors in a packet-oriented manner, use
  72. sized_read() and sized_write().  The sized...() calls read and write one
  73. packet at a time, while packet boundaries are ignored in read() and write().
  74.  
  75.     cc = sized_read(fd,buffer,maxsize)
  76.     cc = sized_write(fd,buffer,size)
  77.  
  78. The arguments for sized_read() and sized_write() are very similar to read()
  79. and write().  The only difference is that in sized_read(), maxsize is the
  80. maximum size of an acceptable packet.
  81.