home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff220.lzh / DNet / doc / dnetlib.doc < prev    next >
Text File  |  1989-06-04  |  4KB  |  92 lines

  1.  
  2. UNIX/DNETLIB
  3.  
  4.     UNIX END DNET LIBRARY INTERFACE
  5.  
  6.     See the server source for good examples of usage.
  7.  
  8. long    private;
  9. uword    port
  10. char     *buf;
  11. int     fd;
  12. int    res1..5, bytes
  13. char    pri;
  14. long    val68, valvax;
  15.  
  16. private    = DListen(port)                listen on a port (server)
  17.      fd = DAccept(private)            accept a connection (server)
  18.       DNAAccept(private)            don't accept a conn.(server)
  19.      fd = DOpen(host, port, txpri, rxpri)    open a remote connection (client)
  20.    res1 = read(fd, buf, bytes)            standard unix read()
  21.    res2 = gread(fd, buf, bytes)            (see below)
  22.    res3 = ggread(fd, buf, bytes)        (see below)
  23.    res4 = write(fd, buf, bytes)            standard unix write()
  24.    res5 = gwrite(fd, buf, bytes)        (see below)
  25.       close(fd);
  26.  
  27.    val68 = ntohl68(valvax)    convert to and from MC68000 longword format.
  28.    valvax= htonl68(val68)
  29.  
  30.  
  31. DListen()    sets up a UNIX domain socket in the current directory unless
  32.         another is specified by the DNETDIR enviroment variable.
  33.         Returns a private structure pointer or NULL on error.
  34.  
  35.         This call will override any existing server for the port in
  36.         the directory permanently.  It does not cause an existing
  37.         server to exit, however, and you should be careful to kill
  38.         old servers before starting new ones.  See the source for a
  39.         template of correct server code.
  40.  
  41. DAccept()    Accepts a new connection on the port.  Returns a file 
  42.         descriptor or a negative value.  This call will block.
  43.  
  44. DOpen()        Attempt to connect to a port on the remote machine.  Returns
  45.         a file descriptor or a negative value.  The error is either
  46.         due to not finding DNET's master port (DNET must be running),
  47.         or the remote server not running.
  48.  
  49.         This call looks in the current directory for the master
  50.         socket unless another is specified by the DNETDIR enviroment 
  51.         variable.
  52.  
  53.         Two priorities are specified.  One for sending, and one for
  54.         receiving data.  A priority is a value -127 to 126 inclusive,
  55.         with 126 the highest priority.  Normally, priorities range
  56.         from -80 (file transfers) to +20 (terminal window).
  57.  
  58. DEof()        Send an EOF without closing the connection.  Currently doesn't
  59.         work worth shit, so don't use it.
  60.  
  61. write()        Standard UNIX write call.  But we are dealing with a socket
  62.         here, so one must be careful of the return value.  (1) WRITE()
  63.         may not return the # bytes requested to write, but less,
  64.         (2) WRITE() may return a negative value indicating an error or
  65.         that it was interrupted or that it would have blocked (if you
  66.         have got non-blocking IO setup).  (3) WRITE() returns 0 on 
  67.         socket EOF.
  68.  
  69. gwrite()    This call will write all the bytes specified, whether the
  70.         socket is non-blocking or not.  It handles restarting the
  71.         WRITE() call on EINTR and properly handles EWOULDBLOCK.
  72.  
  73.         It returns the number bytes requested or fewer on error.  If
  74.         fewer bytes are returned you should close the socket and exit.
  75.  
  76. read()        Standard UNIX read call.  But we are still dealing with a 
  77.         socket here and anything might happen.  READ() can return fewer
  78.         than the number of bytes requested, 0 on EOF, or a negative
  79.         number indicating various errors.
  80.  
  81. gread()        GREAD() handles retrying if the EINTR error occurs.  GREAD()
  82.         blocks until at least one character is received (or EOF), and
  83.         does this even if the socket is marked non-blocking.  GREAD()
  84.         returns 0 on EOF/ERROR.
  85.  
  86. ggread()    GGREAD() not only retries on EINTR, but will block until ALL
  87.         the requested bytes are read in, even if the socket is marked
  88.         non-blocking.  GGREAD() returns -1 on EOF/ERROR.  You can also
  89.         tell if an EOF/ERROR occured if fewer than the requested 
  90.         number of bytes are read.
  91.  
  92.