home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 20 / AACD20.BIN / AACD / Programming / TTCP_SDK / tsocket.doc < prev    next >
Encoding:
Text File  |  1996-07-28  |  47.9 KB  |  1,504 lines

  1. API Function Reference       
  2. **********************
  3. tsocket.library
  4. Version 1.00
  5.  
  6. ©1996 Oregon Research  
  7. All rights reserved.
  8. **********************
  9.  
  10. Portions of this manual are based on original documents from BSD, which 
  11. is hereby acknowledged:
  12.  
  13. *****************************************************************************
  14. Copyright © 1982, 1986, 1990 Regents of the University of California.
  15. All rights reserved.
  16. Redistribution and use in source and binary forms, with or without
  17. modification, are permitted provided that the following conditions
  18. are met:
  19.  
  20. 1. Redistributions of source code must retain the above copyright
  21.    notice, this list of conditions and the following disclaimer.
  22. 2. Redistributions in binary form must reproduce the above copyright
  23.    notice, this list of conditions and the following disclaimer in the
  24.    documentation and/or other materials provided with the distribution.
  25. 3. All advertising materials mentioning features or use of this software
  26.    must display the following acknowledgement: This product includes software 
  27.    developed by the University of California, Berkeley and its contributors.
  28. 4. Neither the name of the University nor the names of its contributors
  29.    may be used to endorse or promote products derived from this software
  30.    without specific prior written permission.
  31.  
  32. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  33. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  34. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35. ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  36. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  38. OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39. HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  40. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  41. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  42. SUCH DAMAGE.
  43. *****************************************************************************
  44.  
  45. tsocket.library  Version 1.00
  46.  
  47. tsocket.library/accept
  48. tsocket.library/bind
  49. tsocket.library/CloseSocket
  50. tsocket.library/connect
  51. tsocket.library/FD_SET, FD_CLR, FD_ISSET, FD_ZERO
  52. tsocket.library/gethostbyaddr
  53. tsocket.library/gethostbyname
  54. tsocket.library/gethostid
  55. tsocket.library/gethostname
  56. tsocket.library/getprotobyname
  57. tsocket.library/getprotobynumber
  58. tsocket.library/getservbyname
  59. tsocket.library/getsockname
  60. tsocket.library/inet_addr
  61. tsocket.library/inet_ntoa
  62. tsocket.library/IoctlSocket
  63. tsocket.library/listen
  64. tsocket.library/recv
  65. tsocket.library/recvfrom
  66. tsocket.library/send
  67. tsocket.library/sendto
  68. tsocket.library/SetErrnoPtr
  69. tsocket.library/SetSocketSignals
  70. tsocket.library/setsockopt
  71. tsocket.library/shutdown
  72. tsocket.library/socket
  73. tsocket.library/SocketBaseTagList
  74. tsocket.library/WaitSelect
  75.  
  76. ******************************************************************************
  77.  
  78. What is tsocket.library?
  79.  
  80.    The primary programmer's interface to Internet network protocols 
  81. is the Berkley Software Distribution socket abstraction.  tsocket.library 
  82. is a link library providing you access to network programming. We recommend 
  83. that you acquire the books "Unix Network Programming" by W. Richard Stephens
  84. (Prentice-Hall, 1990) and "Internetworking with TCP/IP, Volume II" by Douglas 
  85. Comer and David Stephens (Prentice-Hall, 1991).  Writing programs using TCP/IP 
  86. and sockets can be difficult and these books provide invaluable information.
  87.    
  88.    Providing the network sfunctions as shared library provides many benefits.  
  89. The most important benefit is that it is easily upgradable.  New libraries
  90. with bug fixes, speed improvements, or additional functions can be utilized 
  91. by existing code without recompilation of client programs.  
  92.  
  93.    This easy extendability is especially important for this first release. 
  94. This function reference is under construction.  Termite TCP contains many more 
  95. functions than are currently documented. In an effort to get this information
  96. out as quickly as possible, this first version of the SDK only documents
  97. the basic functions necessary to write network applications.      
  98.  
  99. Compliation Notes:
  100.  
  101.    TermiteTCP and all client programs must compile with the symbol TERMITE_TCP
  102. defined.  Otherwise, you will get errors from the BSD include files which have 
  103. been modified for conditional compliation.
  104.  
  105.    The majority of tsocket.library calls follow the convention that a zero or 
  106. positive return indicates success, and a -1 return indicates an error, with 
  107. extended error code written to errno(see SetErrorPtr()).
  108.  
  109.    All integers are assumed to be 32-bit.  None are specified as long in order 
  110. to maintain Un*x compatibility.  If you are using a compiler which doesn't use 
  111. 32-bit ints, you must make sure that all ints are converted to longs by your code.
  112.  
  113.    The shared socket library returns a different library base for each OpenLib() 
  114. and uses these different library bases to keep track of some global data for 
  115. each opener.  If you start a new process with a new context, the new process 
  116. must open and initialize socket.library such as shown below.
  117.  
  118. Example:
  119.  
  120. /* the next three lines must always be here */
  121.  
  122. #include <pragmas/tsocket_pragmas.h>
  123. #include <proto/tsocket.h>
  124.  
  125. struct Library *TSocketBase;
  126.  
  127. /* your includes here */
  128.  
  129.  
  130. main()
  131. {
  132.    if((TSocketBase = OpenLibrary( "tsocket.library", 1L )) == NULL) {
  133.       printf("Error opening tsocket.library\n");
  134.       Exit(10);
  135.    }
  136.    
  137.    ...
  138.    your code here
  139.    ...
  140.  
  141.    CloseLibrary( TSocketBase ) ;
  142. }
  143.  
  144. ******************************************************************************
  145. tsocket.library API Function Reference
  146. ******************************************************************************
  147.  
  148. ******************************************************************************
  149. accept
  150. ******************************************************************************
  151. NAME
  152.    accept -- accept a connection on a socket
  153.  
  154. SYNOPSIS
  155.    #include <sys/types.h>
  156.    #include <sys/socket.h>
  157.  
  158.    int accept(int s, struct sockaddr *addr, int *addrlen)
  159.    D0            D0                    A0          A1
  160.  
  161. DESCRIPTION
  162.    The connections are accept()ed on a socket which on which bind() 
  163.    and listen() have been executed.  Unless there is an error, accept() 
  164.    will return a new socket which is connected. 
  165.  
  166.    accept() looks for a pending connection and creates a new socket with 
  167.    the same properties of s. If ther are no pending connections and the 
  168.    socket is non-blocking accept() blocks the caller andf waits for a 
  169.    connection.  If the socket is non-blocking and there are no pending 
  170.    connections, accept() returns an error as described below.  
  171.  
  172.    The accepted socket is used to read and write data to and from the socket 
  173.    which connected to this one(using send and recv). It is not used to accept 
  174.    more connections.  The original socket s remains open.
  175.  
  176. INPUTS
  177.    s
  178.       is a socket created with socket()
  179.   
  180.    addr  
  181.       is is filled in with the address of the connecting entity.  The 
  182.       exact format of the addr parameter is determined by the domain in 
  183.       which the communication is occurring.  
  184.  
  185.    addrlen
  186.       should initially contain the amount of space pointed to by addr, on 
  187.       return it will contain the actual length (in bytes) of the address 
  188.       returned.  This call is used with connection-based socket types, 
  189.       currently with SOCK_STREAM.
  190.  
  191. RETURNS
  192.    The call returns -1 on error.  If it succeeds, it returns a
  193.    non-negative integer that is a descriptor for the accepted socket.
  194.  
  195. ERRORS
  196.    EBADF
  197.       The descriptor is invalid.
  198.  
  199.    EINTR
  200.       The operation was interrupted by a break signal.
  201.  
  202.    EOPNOTSUPP
  203.       The referenced socket is not of type SOCK_STREAM.
  204.  
  205.    EWOULDBLOCK
  206.       The socket is non-blocking and no connections are present to be accepted.
  207.  
  208. SEE ALSO
  209. bind(), connect(), listen(), select(), SetSocketSignals(), socket()
  210.  
  211. ******************************************************************************
  212. bind
  213. ******************************************************************************
  214.  
  215. NAME
  216.    bind -- bind a name to a socket
  217.  
  218. SYNOPSIS
  219.    #include <sys/types.h>
  220.    #include <sys/socket.h>
  221.  
  222.    int bind(int s, struct sockaddr *name, int namelen)
  223.    D0          D0                    A0        D1
  224.  
  225. DESCRIPTION
  226.    Bind() assigns a name to an unnamed socket.  When a socket is created 
  227.    with socket() it exists in a name space (address family) but has no name 
  228.    assigned.  Bind() requests that name be assigned to the socket.
  229.  
  230. INPUTS
  231.    s  
  232.       socket descriptor.
  233.  
  234.    name
  235.       address to bind to socket 's.'
  236.  
  237.    namelen
  238.       length (in bytes) of 'name.'
  239.  
  240. RETURNS
  241.    If the bind is successful, a 0 value is returned.  
  242.    A return value of -1 indicates an error.
  243.  
  244. ERRORS
  245.    EBADF
  246.       S is not a valid descriptor.
  247.  
  248.    EADDRNOTAVAIL
  249.       The specified address is not available from the local machine.
  250.  
  251.    EADDRINUSE
  252.       The specified address is already in use.
  253.  
  254.    EINVAL
  255.       The socket is already bound to an address.
  256.  
  257.    EACCES
  258.       The requested address is protected, and the current user has
  259.           inadequate permission to access it.
  260.  
  261. SEE ALSO
  262. connect(), listen(), socket(), getsockname()
  263.  
  264. ******************************************************************************
  265. CloseSocket
  266. ******************************************************************************
  267.  
  268. NAME
  269.    CloseSocket -- delete a socket descriptor
  270.  
  271. SYNOPSIS
  272.    int CloseSocket(int s)
  273.    D0                 D0
  274.  
  275. DESCRIPTION
  276.    The CloseSocket() call deletes a descriptor from the socket reference 
  277.    table.  If this is the last reference to the socket, it will be 
  278.    deleted and associated naming information and queued data are discarded.
  279.  
  280.    All sockets are closed when the socket library is closed, but closing 
  281.    sockets as soon as possible is recommended to save system resources.
  282.  
  283. INPUTS
  284.    s
  285.       socket descriptor
  286.  
  287. RETURNS
  288.    0  on success
  289.    -1 on error
  290.  
  291. ERRORS
  292.    EBADF
  293.       S is not an active socket descriptor.
  294.  
  295.    EINTR
  296.       An interupt was received.
  297.  
  298. SEE ALSO
  299. accept(), shutdown(), socket(),
  300.  
  301. ******************************************************************************
  302. connect
  303. ******************************************************************************
  304.  
  305. NAME
  306.    connect -- initiate a connection on a socket
  307.  
  308. SYNOPSIS
  309.    #include <sys/types.h>
  310.    #include <sys/socket.h>
  311.  
  312.    int connect(int s, struct sockaddr *name, int namelen)
  313.    D0             D0                    A0        D1
  314.  
  315. DESCRIPTION
  316.  
  317.    To communicate with a server using TCP, the client must connect() 
  318.    a socket obtained by the client (from socket()) to the server's 
  319.    well-known address.  (The server will receive (from accept()) a new 
  320.    socket which is connected to the socket which the client is connect()ing 
  321.    to the server.)  Most clients should build 'name' from a well-known port 
  322.    obtained from getservbyname().  
  323.  
  324.    If s is of type SOCK_DGRAM, this call specifies the peer with which the 
  325.    socket is to be associated. If the socket is of type SOCK_STREAM, this 
  326.    call attempts to make a connection to the named socket.  Generally, stream 
  327.    sockets may successfully connect() only once; datagram sockets may use 
  328.    connect() multiple times to change their association.  Datagram sockets may
  329.    dissolve the association by connecting to an invalid address, such
  330.    as a null address.
  331.  
  332. INPUTS
  333.    s
  334.       socket descriptor.
  335.  
  336.    name  
  337.       address of socket to connect 's' to.
  338.  
  339.    namelen
  340.       length of 'name.'
  341.  
  342. RETURNS
  343.      0 on success
  344.      -1 on error
  345.  
  346. ERRORS
  347.    EBADF
  348.       S is not a valid descriptor.
  349.  
  350.    EADDRNOTAVAIL
  351.       The specified address is not available on this machine.
  352.  
  353.    EAFNOSUPPORT
  354.       Addresses in the specified family cannot be used with this socket.
  355.  
  356.    EISCONN
  357.       The socket is already connected.
  358.  
  359.    ETIMEDOUT
  360.       Connection establishment timed out without establishing a connection.
  361.  
  362.    ECONNREFUSED
  363.       The attempt to connect was rejected
  364.  
  365.    EUNREACH
  366.           The network isn't reachable from this host.
  367.  
  368.    EADDRINUSE
  369.       The address is already in use.
  370.  
  371.    EINPROGRESS
  372.       The socket is non-blocking and the connection cannot be completed 
  373.       immediately.  It is possible to select() for completion by selecting 
  374.       the socket for writing.
  375.  
  376.    EALREADY
  377.       The socket is non-blocking and a previous connection attempt has not 
  378.       yet been completed.
  379.  
  380. SEE ALSO
  381.    accept(), select(), socket(), getsockname()
  382.  
  383. ****************************************************************************
  384. FD_SET, FD_CLR, FD_ISSET, FD_ZERO
  385. ****************************************************************************
  386. NAME
  387.    FD_SET, FD_CLR, FD_ISSET, FD_ZERO - Macros to manipulate socket masks.
  388.  
  389. SYNOPSIS
  390.    #include <sys/types.h>
  391.  
  392.    FD_SET(socket, mask)
  393.    FD_CLR(socket, mask)
  394.    result = FD_ISSET(socket, mask)
  395.    FD_ZERO(mask)
  396.  
  397. DESCRIPTION
  398.    Type fd_set contains masks for use with sockets and WaitSelect().
  399.    To manipulate socket masks you must use the FD_*() macros.
  400.  
  401.    FD_SET() sets the "bit" for 'socket' in 'mask.'
  402.  
  403.    FD_CLR() clears the "bit" for 'socket' in 'mask.'
  404.  
  405.    FD_ISSET() returns non-zero if the "bit" for 'socket' in 'mask' is
  406.    set, else zero.
  407.  
  408.    FD_ZERO() clears all "bits" in 'mask.'  FD_ZERO should be used
  409.    to initialize an fd_set variable before it is used.
  410.  
  411. SEE ALSO
  412.     WaitSelect()
  413.  
  414. ******************************************************************************
  415. gethostbyname, gethostbyaddr
  416. ******************************************************************************
  417.  
  418. NAME
  419.    gethostbyname, gethostbyaddr -- get network host entry
  420.  
  421. SYNOPSIS
  422.    #include <netdb.h>
  423.    extern struct h_errno;
  424.  
  425.    struct hostent * gethostbyname(char *name)
  426.    D0                                    A0
  427.  
  428.    struct hostent * gethostbyaddr(char *addr, int len, int type)
  429.    D0                                    A0        D0       D1
  430.  
  431. DESCRIPTION/RETURNS
  432.  
  433.    These functions return a pointer to an object with the following structure 
  434.    describing an internet host referenced by name or by address, respectively.
  435.    This structure contains either the information obtained from the name server.
  436.  
  437.    struct  hostent {
  438.            char    *h_name;        /* official name of host */
  439.            char    **h_aliases;    /* alias list */
  440.            int     h_addrtype;     /* host address type */
  441.            int     h_length;       /* length of address */
  442.            char    **h_addr_list;  /* list of addresses from name server */
  443.    };
  444.  
  445.    The members of this structure are:
  446.    h_name
  447.       Official name of the host.
  448.  
  449.    h_aliases
  450.       A zero terminated array of alternate names for the host.
  451.  
  452.    h_addrtype
  453.       The type of address being returned; currently always AF_INET.
  454.  
  455.    h_length
  456.       The length, in bytes, of the address.
  457.  
  458.    h_addr_list
  459.       A zero terminated array of network addresses for the host. Host 
  460.       addresses are returned in network byte order.
  461.  
  462.  
  463. ERRORS
  464.    Error return status from gethostbyname() and gethostbyaddr() is indicated 
  465.    by return of a null pointer.  The library integer h_errno may be checked
  466.    for more information about the failure.
  467.  
  468.    The library variable h_errno can have the following values:
  469.    HOST_NOT_FOUND
  470.       No such host is known.
  471.  
  472.    TRY_AGAIN
  473.       This is usually a temporary error and means that the local server did 
  474.       not receive a response from the name server.  A retry at some later 
  475.       time may succeed.
  476.  
  477.    NO_RECOVERY
  478.       Some unexpected non-recoverable error.
  479.  
  480.    NO_DATA
  481.       The requested name is valid but does not have an IP address. This is 
  482.       not a temporary error.  This means that the name is known to the name 
  483.       server but there is no address associated with this name.  
  484.  
  485. *****************************************************************************
  486. gethostid
  487. *****************************************************************************
  488.  
  489. NAME
  490.      gethostid -- get unique IP address of current host
  491.  
  492. SYNOPSIS
  493.      long gethostid(void)
  494.      D0
  495.  
  496. DESCRIPTION
  497.      gethostid() returns the 32-bit identifier for the current processor
  498.      that is intended to be unique among all UNIX systems in existence.
  499.      This is normally the IP address for the local machine.
  500.  
  501. SEE ALSO
  502. gethostname()
  503.  
  504. *****************************************************************************
  505. gethostname
  506. *****************************************************************************
  507.  
  508. NAME
  509.    gethostname -- get name of current host
  510.  
  511. SYNOPSIS
  512.    int gethostname(char *name, int namelen)
  513.    D0                     A0        D0
  514.  
  515. DESCRIPTION
  516.    Gethostname() returns the standard host name for the current processor. 
  517.    The null-terminated hostname is copied into 'name'.  The hostname will
  518.    be truncated if insufficient space is available in 'name'.
  519.  
  520. INPUTS
  521.    name
  522.       pointer to character array.
  523.  
  524.    length
  525.       size of character array.
  526.  
  527. *****************************************************************************
  528. getprotobyname(), getprotobynumber()
  529. *****************************************************************************
  530.  
  531. NAME
  532.    getprotobynumber, getprotobyname -- get protocol entry
  533.  
  534. SYNOPSIS
  535.    #include <netdb.h>
  536.  
  537.    struct protoent * getprotobyname(char *name)
  538.    D0                                      A0
  539.  
  540.    struct protoent * getprotobynumber(int proto)
  541.    D0                                     D0
  542.  
  543. DESCRIPTION
  544.    Thesefunctions each return a pointer to an object with the following 
  545.    structure containing the fields of a line in the network protocol data base.
  546.           
  547.    struct  protoent {
  548.            char    *p_name;        /* official name of protocol */
  549.            char    **p_aliases;    /* alias list */
  550.            int     p_proto;        /* protocol number */
  551.    };
  552.  
  553.    The members of this structure are:
  554.    p_name
  555.       The official name of the protocol.
  556.  
  557.    p_aliases
  558.       A zero terminated list of alternate names for the protocol.
  559.  
  560.    p_proto
  561.       The protocol number.
  562.  
  563. RETURNS
  564.    A null pointer (0) returned on EOF or error.
  565.  
  566. ******************************************************************************
  567. getservbyname()
  568. ******************************************************************************
  569.  
  570. NAME
  571.    getservbyname -- get service entry
  572.  
  573. SYNOPSIS
  574.    #include <netdb.h>
  575.  
  576.    struct servent * getservbyname(char *name, char *proto)
  577.    D0                                    A0           A1
  578.  
  579. DESCRIPTION
  580.    This function returns a pointer to an object with the following structure 
  581.    containing the fields of a line in the network services data base.
  582.    struct  servent {
  583.            char    *s_name;        /* official name of service */
  584.            char    **s_aliases;    /* alias list */
  585.            int     s_port;         /* port service resides at */
  586.            char    *s_proto;       /* protocol to use */
  587.    };
  588.  
  589.    The members of this structure are:
  590.    s_name
  591.       The official name of the service.
  592.  
  593.    s_aliases
  594.       A zero terminated list of alternate names for the service.
  595.  
  596.    s_port
  597.       The port number at which the service resides.  Port numbers are 
  598.       returned in network byte order.
  599.  
  600.    s_proto
  601.       The name of the protocol to use when contacting the service.
  602.  
  603. INPUTS
  604.    name
  605.       name of service to look up.
  606.    proto
  607.       protocol of service to look up.
  608.  
  609. ERRORS
  610.      A null pointer (0) returned on EOF or error.
  611.  
  612. SEE ALSO
  613. getprotobyname() 
  614.  
  615. ***************************************************************************
  616. getsockname
  617. ***************************************************************************
  618.  
  619. NAME
  620.    getsockname -- get socket name
  621.  
  622. SYNOPSIS
  623.    int getsockname(int s, struct sockaddr *name, int *namelen)
  624.    D0                 D0                    A0          A1
  625.  
  626. DESCRIPTION
  627.    Getsockname() returns the current name for the specified socket. The 
  628.    namelen parameter should be initialized to indicate the amount of space 
  629.    pointed to by name.  On return it contains the actual size of the 
  630.    name returned (in bytes).
  631.  
  632. INPUTS
  633.    s
  634.       socket descriptor.
  635.    name
  636.       socket name.
  637.    namelen
  638.       size of 'name' (in bytes).
  639.  
  640. RETURNS
  641.      0 on success
  642.      -1 on failure
  643.  
  644. ERRORS
  645.    EBADF
  646.       The argument s is not a valid descriptor.
  647.  
  648.    ENOBUFS
  649.       Insufficient resources were available to perform the operation.
  650.  
  651. SEE ALSO
  652. bind(), socket()
  653.  
  654. *****************************************************************************
  655. inet_addr, inet_ntoa
  656. *****************************************************************************
  657.  
  658. NAME
  659.    inet_addr - Internet address manipulation routines
  660.    inet_ntoa 
  661.  
  662. SYNOPSIS
  663.    #include <sys/socket.h>
  664.    #include <netinet/in.h>
  665.    #include <arpa/inet.h>
  666.  
  667.    unsigned long inet_addr(const char * cp)
  668.    D0                                   A0
  669.    char *inet_ntoa(struct in_addr in)
  670.  
  671. DESCRIPTION
  672.    inet_addr() converts a character string containing a Internet standard 
  673.    `.'  address notation and returns the actual 32 bit Internet address
  674.  
  675.    inet_ntoa() is the reverse and takes an Internet address and returns 
  676.    an string representing the address in  standard Internet '.' format.
  677.  
  678.    All Internet addresses are returned in network order(from left to right).  
  679.  
  680. SEE ALSO
  681. gethostbyname()
  682.  
  683. *****************************************************************************
  684. IoctlSocket
  685. *****************************************************************************
  686.  
  687. NAME
  688.    IoctlSocket -- control sockets
  689.  
  690. SYNOPSIS
  691.    #include <sys/ioctl.h>
  692.  
  693.    int IoctlSocket(int s, unsigned long request, char * argp)
  694.    D0                 D0                D1              A0
  695.  
  696. DESCRIPTION
  697.    IoctlSocket() performs a special function on the socket descriptor s. 
  698.    For most IoctlSocket() functions, argp is a pointer to data to be used 
  699.    by the  function  or to be filled in by the function.  Other functions 
  700.    may ignore arg or may treat it directly as a data item; they may, for 
  701.    example, be passed an int value.
  702.  
  703.    An ioctl request includes whether the argument is an input parameter or 
  704.    an output parameter, and the size of the argument argp in bytes.  Macros 
  705.    and defines used in specifying an ioctl request are located in the 
  706.    file <sys/ioctl.h>.
  707.  
  708.    The following requests are supported:
  709.  
  710.    FIOASYNC
  711.       The argument is a pointer to a long.  Set or clear asynchronous I/O.  
  712.       If the value of that long is a 1 (one) the descriptor is set for 
  713.       asynchronous I/O.  If the value of that long is a 0 (zero) the 
  714.       descriptor is cleared for asynchronous I/O.
  715.  
  716.    FIOCLEX
  717.    FIONCLEX
  718.       Ignored, no use for close-on-exec flag in Amiga.
  719.  
  720.    FIOGETOWN
  721.    SIOCGPGRP
  722.       The argument is pointer to struct Task*.  Set the value of that pointer 
  723.       to the Task that is receiving SIGIO or SIGURG signals for the socket 
  724.       referred to by the descriptor passed to IoctlSocket().
  725.  
  726.    FIONBIO
  727.       The argument is a pointer to a long.  Set or clear non-blocking I/O.  
  728.       If the value of that long is a 1 (one) the descriptor is set for 
  729.       non-blocking I/O.  If the value of that long is a 0 (zero) the 
  730.       descriptor is cleared for non-blocking I/O.
  731.  
  732.    FIONREAD
  733.       The argument is a pointer to a long.  Set the value of that long to 
  734.       the number of immediately readable characters from the socket fd.
  735.  
  736.    FIOSETOWN
  737.    SIOCSPGRP
  738.       The argument is pointer to struct Task*, pointer to the task that 
  739.       will subsequently receive SIGIO or SIGURG signals for the socket 
  740.       referred to by the descriptor passed.
  741.  
  742.    SIOCCATMARK
  743.       The argument is a pointer to a long.  Set the value of that long to 1 
  744.       if the read pointer for the socket referred to by the descriptor passed 
  745.       to IoctlSocket() points to a mark in the data stream for an out-of-band 
  746.       message, and to 0 if it does not point to a mark.
  747.  
  748. RETURNS
  749.       0 on success for most requests. Some specialized requests may return 
  750.         a positive non-zero values on success 
  751.  
  752.       -1 on failure and sets errno to indicate the error.
  753.  
  754. ERRORS
  755.    EBADF
  756.       s is not a valid descriptor.
  757.  
  758.    EINVAL
  759.       Request or argp is not valid.
  760.  
  761. ******************************************************************************
  762. listen
  763. ******************************************************************************
  764.  
  765. NAME
  766.    listen -- listen for connections on a socket
  767.  
  768. SYNOPSIS
  769.    #include <sys/socket.h>
  770.  
  771.    int listen(int s, int backlog)
  772.    D0            D0      D1
  773.  
  774. DESCRIPTION
  775.    This function is used to indicate that a socket it is waiting to receive 
  776.    connections.  It is usually executed after socket() and bind(), and 
  777.    before accept().
  778.  
  779.    To accept connections, a socket is first created with socket(), a 
  780.    willingness to accept incoming connections and a queue limit are then
  781.    specified with listen() and then the connections are accepted with 
  782.    accept().  The listen() call applies only to sockets of type 
  783.    SOCK_STREAM or SOCK_SEQPACKET.
  784.  
  785.    The backlog parameter defines the maximum length the queue of pending 
  786.    connections may grow to.  If a connection request arrive with the queue 
  787.    full the client may receive an error with an indication of ECONNREFUSED, 
  788.    or, if the underlying protocol supports retransmission, the request may 
  789.    be ignored so that retries may succeed.
  790.  
  791. NPUTS
  792.    s
  793.       socket descriptor.
  794.  
  795.    backlog
  796.       max number of connection requests to queue (usually 5).
  797.  
  798. RETURNS
  799.      0 on success
  800.     -1 on an error.
  801.  
  802. ERRORS
  803.    EBADF
  804.       The argument s is not a valid descriptor.
  805.  
  806.    EOPNOTSUPP
  807.       The socket is not of a type that supports the operation listen()
  808.  
  809. SEE ALSO
  810. accept(), connect(), socket()
  811.  
  812. ***************************************************************************
  813. recv, recvfrom
  814. ***************************************************************************
  815.  
  816. NAME
  817.    recv, recvfrom -- receive a message from a socket
  818.  
  819. SYNOPSIS
  820.    #include <sys/types.h>
  821.    #include <sys/socket.h>
  822.  
  823.    int recv(int s, void *buf, int len, int flags)
  824.    D0          D0         A0       D1       D2
  825.  
  826.    int recvfrom(int s, void *buf, int len, int flags,
  827.    D0             D0       A0        D1        D2 
  828.                 struct sockaddr *from, int *fromlen)
  829.                                   A1           A2
  830.  
  831. DESCRIPTION
  832.    recv() is used to receive messages on an already connect()ed socket.
  833.  
  834.    recvfrom() receives data from a socket whether it is in a connected 
  835.    state or not.
  836.  
  837.    If no data is available at the socket, the receive call waits for data 
  838.    to arrive, unless the socket is nonblocking (see IoctlSocket()) in which 
  839.    case the value -1 is returned and variable errno is set to EWOULDBLOCK.  
  840.  
  841.    The receive calls normally return any data available, up to the requested 
  842.    amount, rather than waiting for receipt of the full amount requested; 
  843.    this behavior is affected by the socket-level options SO_RCVLOWAT and 
  844.    SO_RCVTIMEO described in setsockopt().
  845.  
  846.    The WaitSelect() call may be used to determine when more data arrive.
  847.  
  848.    The flags argument to a recv call is formed by or'ing one or more
  849.    of the values:
  850.       MSG_OOB
  851.          process out-of-band data
  852.  
  853.       MSG_PEEK
  854.          peek at incoming message
  855.  
  856.       MSG_WAITALL
  857.          wait for full request or error
  858.  
  859.    The MSG_OOB flag requests receipt of out-of-band data that would not be 
  860.    received in the normal data stream.  The MSG_PEEK flag causes the receive 
  861.    operation to return data from the beginning of the receive queue without 
  862.    removing that data from the queue.  The MSG_WAITALL flag requests that the 
  863.    operation block until the full request is satisfied.  The call may still 
  864.    return less data than requested if a signal is caught, an error or
  865.    disconnect occurs, or the next data to be received is of a different type 
  866.    than that returned.
  867.  
  868. INPUTS
  869.    s
  870.       a socket descriptor.
  871.    buf
  872.       the buffer into which the incoming data will be placed.
  873.  
  874.    len
  875.       the size of the buffer.
  876.  
  877.    flags
  878.       select options (MSG_OOB, MSG_PEEK).
  879.  
  880.    from
  881.       a pointer to a sockaddr structure.
  882.  
  883.    fromlen
  884.       Length of the 'from' buffer.
  885.  
  886.    msg
  887.       pointer to a struct msghdr, defined in "sys/socket.h."
  888.  
  889. RETURNS
  890.    These calls return the number of bytes received, or -1 if an error
  891.    occurred.
  892.  
  893. ERRORS
  894.    EBADF
  895.       The argument s is an invalid descriptor.
  896.  
  897.    ENOTCONN
  898.       The socket is assoicated with a connection-oriented protocol and has 
  899.       not been connected (see connect() and accept()).
  900.  
  901.    EWOULDBLOCK
  902.       The socket is marked non-blocking, and the receive operation would 
  903.       block, or a receive timeout had been set, and the timeout expired 
  904.       before data were received.
  905.  
  906.    EINTR
  907.       The receive was interrupted by delivery of a signal before any data 
  908.       were available.
  909.  
  910. SEE ALSO
  911. IoctlSocket(), select(), send(), setsockopt(), socket()
  912.  
  913. ******************************************************************************
  914. send(), sendto()
  915. ******************************************************************************
  916.  
  917. NAME
  918.    send, sendto -- send a message from a socket
  919.  
  920. SYNOPSIS
  921.    #include <sys/types.h>
  922.    #include <sys/socket.h>
  923.  
  924.    int send(int s, const void *buf, int len, int flags)
  925.    D0          D0               A0       D1       D2
  926.  
  927.    int sendto(int s, const void *buf, int len, int flags,
  928.    D0           D0         A0            D1        D2
  929.                 const struct sockaddr * to, int to_len)
  930.                            A1                  D3
  931.  
  932. DESCRIPTION
  933.    send(), sendto() are used to transmit data to another socket.  
  934.    send() may be used only when the socket is in a connected state, 
  935.    while sendto() and may be used at any time.
  936.  
  937.    If no  data space is available at the socket to hold the message to be 
  938.    transmitted, then send() normally blocks, unless the socket has been 
  939.    placed in non-blocking I/O mode.  Then WaitSelect() may be used to 
  940.    determine when it is possible to send more data.
  941.  
  942.    The flags parameter may include one or more of the following:
  943.    #define MSG_OOB        0x1  /* process out-of-band data */
  944.    #define MSG_DONTROUTE  0x4  /* bypass routing, use direct interface */
  945.  
  946.    The flag MSG_OOB is used to send "out-of-band" data on sockets that 
  947.    support this notion (e.g.  SOCK_STREAM); the underlying protocol must 
  948.    also support "out-of-band" data.  MSG_DONTROUTE is usually used only 
  949.    by diagnostic or routing programs.
  950.  
  951. INPUTS
  952.    s
  953.       socket descriptor.
  954.  
  955.    buf
  956.       pointer to data buffer.
  957.  
  958.    len
  959.       length of data to transmit.
  960.  
  961.    flags
  962.       0 or MSG_OOB to send out-of-band data.
  963.  
  964.    to
  965.       pointer to a sockaddr containing the destination.
  966.  
  967.    to_len
  968.       sizeof(struct sockaddr).
  969.  
  970. RETURNS
  971.      The call returns the number of characters sent, or -1 if an error occurred.
  972.  
  973. ERRORS
  974.    EBADF
  975.       An invalid descriptor was specified.
  976.  
  977.    EMSGSIZE
  978.       The socket requires that message be sent atomically, and the size of 
  979.       the message to be sent made this impossible.
  980.  
  981.    EWOULDBLOCK
  982.       The socket is marked non-blocking and the requested operation would block.
  983.  
  984.    ENOBUFS
  985.       The system was unable to allocate an internal buffer.  The operation 
  986.       may succeed when buffers become available.
  987.  
  988.    ENOBUFS
  989.       The output queue for a network interface was full.  This generally 
  990.       indicates that the interface has stopped sending, but may be caused 
  991.       by transient congestion.
  992.  
  993. SEE ALSO
  994.    IoctlSocket(), recv(), select(), setsockopt(), socket()
  995.  
  996. *****************************************************************************
  997. SetErrnoPtr()
  998. *****************************************************************************
  999.  
  1000. NAME
  1001.    SetErrnoPtr -- set the "global" errno pointer 
  1002.  
  1003. SYNOPSIS
  1004.    void SetErrnoPtr(void * ptr, int size)
  1005.                              A0       D0
  1006.  
  1007. DESCRIPTION
  1008.    This functions allows caller to redirect error variable inside scope of 
  1009.    caller task.  Usually this is used to make task's global variable errno as 
  1010.    error variable.
  1011.  
  1012. INPUTS
  1013.    ptr
  1014.       pointer to error variable that is to be modified on every error 
  1015.       condition on this library function.
  1016.  
  1017.    size
  1018.       size of the error variable. It can be 1, 2 or 4 bytes long.
  1019.  
  1020. EXAMPLE
  1021.              #include <sys/errno.h>
  1022.      
  1023.              struct Library;
  1024.              struct Library *TSocketBase = NULL;
  1025.      
  1026.              int main(void)
  1027.              {
  1028.                 ...
  1029.                if ((TSocketBase = OpenLibrary("tsocket.library", 2))
  1030.                    != NULL) {
  1031.                  SetErrnoPtr(&errno, sizeof errno);
  1032.                 ...
  1033.                }
  1034.              }
  1035.  
  1036. ****************************************************************************
  1037. SetSocketSignals
  1038. ****************************************************************************
  1039.  
  1040. NAME
  1041.    SetSocketSignals -- set SIGINTR, SIGIO and SIGURG signals
  1042.  
  1043. SYNOPSIS
  1044.    void SetSocketSignals(ULONG intrmask, ULONG iomask, ULONG urgmask)
  1045.                                D0              D1            D2
  1046.  
  1047. DESCRIPTION
  1048.    SetSocketSignals() tells the TermiteTCP which signal masks correspond 
  1049.    to the standard UNIX signals SIGINT, SIGIO and SIGURG. The signals are 
  1050.    sent only to the owning task of particular socket. The task that creates 
  1051.    the socket is set to the owner of the socket.
  1052.  
  1053.    Note that the supplied values write over old ones. If this function is 
  1054.    used and CTRL-C is still wanted to interrupt the calls (the default 
  1055.    behaviour), the value SIGBREAKF_CTRL_C must be explicitly or'ed to the 
  1056.    intrmask.
  1057.  
  1058. INPUTS
  1059.    intrmask
  1060.       Used to determine which Amiga signals interrupt blocking library calls.
  1061.  
  1062.    iomask 
  1063.       is sent when asynchronous notification of socket event is done 
  1064.  
  1065.    urgmask
  1066.       is sent when out-of-band data arrives.
  1067.  
  1068.      The signals are sent only to the owning task of particular socket.
  1069.      The task that creates the socket is set to the owner of the
  1070.      socket by default. If the socket is inherited with the
  1071.      ObtainSocket() function, the owner must be set explicitly with the
  1072.      FIOSETOWN (SIOCSPGRP) IoctlSocket() call.
  1073.  
  1074.      Note that the supplied values write over old ones. If this
  1075.      function is used and CTRL-C is still wanted to interrupt the calls
  1076.      (the default behaviour), the value SIGBREAKF_CTRL_C must be
  1077.      explicitly or'ed to the intrmask.
  1078.  
  1079. ****************************************************************************
  1080. setsockopt
  1081. ****************************************************************************
  1082.  
  1083. NAME
  1084.    setsockopt -- set options on sockets
  1085.  
  1086. SYNOPSIS
  1087.    #include <sys/types.h>
  1088.    #include <sys/socket.h>
  1089.  
  1090.    int setsockopt(int s, int level,
  1091.    D0                 D0     D1
  1092.                   int optname, const void *optval, int optlen)
  1093.                       D2                    A0          D3
  1094.  
  1095. DESCRIPTION
  1096.    setsockopt() manipulate the options associated with a socket.  To
  1097.    manipulate options at the socket level, level is specified as SOL_SOCKET.  
  1098.    To manipulate options at any other level the protocol number of the 
  1099.    appropriate protocol controlling the option is supplied.  For example, to 
  1100.    indicate that an option is to be interpreted by the TCP protocol, level 
  1101.    should be set to the protocol number of TCP; see getprotobyname().
  1102.  
  1103.    The include file <sys/socket.h> contains definitions for socket level 
  1104.    options, described below.  Options at other protocol levels vary in format
  1105.    and name.
  1106.  
  1107.    The following options are recognized at the socket level.  
  1108.       SO_DEBUG
  1109.          enables recording of debugging information
  1110.  
  1111.       SO_REUSEADDR
  1112.          enables local address reuse
  1113.  
  1114.       SO_KEEPALIVE
  1115.          enables keep connections alive
  1116.  
  1117.       SO_DONTROUTE
  1118.          enables routing bypass for outgoing messages
  1119.  
  1120.       SO_LINGER
  1121.          linger on close if data present
  1122.  
  1123.       SO_BROADCAST
  1124.          enables permission to transmit broadcast messages
  1125.  
  1126.       SO_OOBINLINE
  1127.          enables reception of out-of-band data in band
  1128.  
  1129.       SO_SNDBUF
  1130.          set buffer size for output
  1131.  
  1132.       SO_RCVBUF
  1133.          set buffer size for input
  1134.  
  1135.       SO_SNDLOWAT
  1136.          set minimum count for output
  1137.  
  1138.       SO_RCVLOWAT
  1139.          set minimum count for input
  1140.  
  1141.       SO_SNDTIMEO
  1142.          set timeout value for output
  1143.  
  1144.       SO_RCVTIMEO
  1145.          set timeout value for input
  1146.  
  1147.       SO_EVENTMASK
  1148.          set event mask to specify which events should be notified to the 
  1149.          application
  1150.  
  1151. INPUTS
  1152.    s
  1153.       socket descriptor.
  1154.  
  1155.    level
  1156.       protocol level.  Valid levels are:
  1157.          IPPROTO_IP  IP options
  1158.          IPPROTO_TCP TCP options
  1159.          SOL_SOCKET  socket options
  1160.  
  1161.    optname
  1162.       option name.
  1163.  
  1164.    optval
  1165.       pointer to the buffer with the new value.
  1166.  
  1167.    optlen
  1168.       size of 'optval' (in bytes).
  1169.  
  1170. RETURNS
  1171.    0 on success
  1172.   -1 if it fails.
  1173.  
  1174. ERRORS
  1175.    EBADF
  1176.       The argument s is not a valid descriptor.
  1177.  
  1178.    ENOPROTOOPT
  1179.       The option is unknown at the level indicated.
  1180.  
  1181. SEE ALSO
  1182. IoctlSocket(), socket(), getprotobyname()
  1183.  
  1184. ***************************************************************************
  1185. shutdown
  1186. ***************************************************************************
  1187.  
  1188. NAME
  1189.    shutdown -- shut down part of a full-duplex connection
  1190.  
  1191. SYNOPSIS
  1192.    #include <sys/socket.h>
  1193.  
  1194.    int shutdown(int s, int how)
  1195.    D0              D0      D1
  1196.  
  1197. DESCRIPTION
  1198.    Sockets are normally terminated by using just CloseSocket.  However,
  1199.    this will attempt to deliver any data that is still pending.    
  1200.    shutdown() provides more control over how a connection is terminated.  
  1201.    You should still eventually use CloseSocket  on all sockets you
  1202.    own, regardless of what shutdown() is done on those sockets.
  1203.  
  1204. INPUTS
  1205.    s
  1206.       socket descriptor.
  1207.  
  1208.    how
  1209.       'how' can be one of the following:
  1210.          0  disallow further receives
  1211.          1  disallow further sends
  1212.          2  disallow further sends and receives
  1213.  
  1214. RETURNS
  1215.     
  1216.    0 if successful
  1217.   -1 on failure (errno will contain the specific error).
  1218.  
  1219. SEE ALSO
  1220. CloseSocket(), connect(), socket()
  1221.  
  1222. ****************************************************************************
  1223. socket()
  1224. ****************************************************************************
  1225.  
  1226. NAME
  1227.    socket - create an endpoint for communication
  1228.  
  1229. SYNOPSIS
  1230.    #include <sys/types.h>
  1231.    #include <sys/socket.h>
  1232.  
  1233.    int socket(int family, int type, int protocol)
  1234.    D0             D0          D1        D2
  1235.  
  1236. DESCRIPTION
  1237.    Socket() creates an endpoint for communication and returns a socket
  1238.    descriptor.
  1239.  
  1240.    Sockets of type SOCK_STREAM are full-duplex byte streams, similar to pipes.  
  1241.    A stream socket must be in a connected state before any data may be sent 
  1242.    or received on it.  A connection to another socket is created with a 
  1243.    connect() call.  Once connected, data may be transferred using recv() 
  1244.    and send() or their variant calls.  When a session has been completed a 
  1245.    CloseSocket() may be performed.  Out-of-band data may also be transmitted 
  1246.    as described in send() and received as described in recv().
  1247.  
  1248.  
  1249. INPUTS
  1250.    family
  1251.       This specifies an address format with which addresses specified in 
  1252.       later operations using socket should be interpreted. TermiteTCP 
  1253.       currently supports only AF_INET protocol family.
  1254.  
  1255.    type
  1256.       Specifies the semantics of communication. Currently available types are:
  1257.  
  1258.          SOCK_STREAM  
  1259.             provides sequenced, reliable, two-way connection based byte 
  1260.             streams.  An out-of-band data transmission mechanism may be supported.  
  1261.  
  1262.          SOCK_DGRAM
  1263.             supports datagrams(connectionless, unreliable messages of a 
  1264.             fixed (typically small) maximum length.
  1265.  
  1266.          SOCK_RAW
  1267.             provide access to internal network protocols and interfaces.  
  1268.             Available only to the super-user, 
  1269.    protocol
  1270.       Specifies a particular protocol to be used with the socket.
  1271.  
  1272. RETURN VALUES
  1273.      On success, the return value is a socket descriptor. 
  1274.      A -1 is returned if an error occurs, 
  1275.  
  1276. ERRORS
  1277.    EPROTONOSUPPORT
  1278.       The protocol type or the specified protocol is not supported within 
  1279.       this domain.
  1280.  
  1281.    EMFILE
  1282.       The per-process descriptor table is full.
  1283.  
  1284.    EACCESS
  1285.       Permission to create a socket of the specified type and/or protocol 
  1286.       is denied.
  1287.  
  1288.    ENOBUFS
  1289.       Insufficient buffer space is available.  The socket cannot be created 
  1290.       until sufficient resources are freed.
  1291.  
  1292. SEE ALSO
  1293.    accept(), bind(), connect(), CloseSocket(), getprotobyname(),
  1294.    getsockname(), getsockopt(), IoctlSocket(), listen(), recv(),
  1295.    select(), send(), shutdown()
  1296.  
  1297.    "An Introductory 4.3 BSD Interprocess Communication Tutorial",
  1298.     reprinted in UNIX Programmer's Supplementary Documents Volume 1.
  1299.  
  1300.    "BSD Interprocess Communication Tutorial", reprinted in UNIX
  1301.     Programmer's Supplementary Documents Volume 1.
  1302.  
  1303. ****************************************************************************
  1304. SocketBaseTagList
  1305. ****************************************************************************
  1306.  
  1307. NAME
  1308.    SocketBaseTagList -- Set/Get SocketBase attributes.
  1309.  
  1310. SYNOPSIS
  1311.    #include <sys/socketbasetags.h>
  1312.  
  1313.    ULONG SocketBaseTagList(struct TagItem * taglist);
  1314.    D0                                       A0
  1315.  
  1316. DESCRIPTION
  1317.    Set or get a list of SocketBase instance dependent attributes
  1318.  
  1319. INPUTS
  1320.    These functions expect as their argument a standard tag list, one or several 
  1321.    arrays of struct TagItem as defined in the standard Amiga header file
  1322.    <utility/tagitem.h>. The structure contains two fields: ti_Tag and ti_Data.  
  1323.    The ti_Tag field contains tag code, which determines what the 
  1324.    SocketBaseTagList() should do with its argument, the ti_Data field.
  1325.  
  1326.    The include file <sys/socketbasetags.h> defines macros for base tag code 
  1327.    values.  Base tag code macros begin with `SBTC_' (as Socket Base Tag Code).  
  1328.    The base tag value defines what data item the tag item refers.
  1329.  
  1330.    The tag code contains other information besides the referred data item.  It 
  1331.    controls, whether the SocketBaseTagList() should set or get the appropriate 
  1332.    parameter, and whether the argument of the tag in question is passed by value 
  1333.    or by reference.
  1334.  
  1335.    The include file <sys/socketbasetags.h> defines the following macros, which 
  1336.    are used to construct the ti_Tag values from the base tag codes:
  1337.           SBTM_GETREF(code) - get by reference
  1338.           SBTM_GETVAL(code) - get by value
  1339.           SBTM_SETREF(code) - set by reference
  1340.           SBTM_SETVAL(code) - set by value
  1341.  
  1342.    If the actual data is stored directly into the ti_Data field, you should use 
  1343.    the 'by value' macros, SBTM_GETVAL() or SBTM_SETVAL(). However, if the ti_Data 
  1344.    field contains a pointer to actual data, you should use the 'by reference' 
  1345.    macros, SBTM_GETREF() or SBTM_SETREF().  The actual data should always be a 
  1346.    LONG aligned to even address.
  1347.  
  1348.    According the used tag naming scheme a tag which has "PTR" suffix takes an 
  1349.    pointer as its argument.  Do not mix the pointer arguments with 
  1350.    'by reference' argument passing.  It is possible to pass a pointer by 
  1351.    reference (in which case the ti_Data is a pointer to the actual pointer).
  1352.  
  1353.    The list of the currently defined base tag codes is as follows:
  1354.  
  1355.    SBTC_BREAKMASK
  1356.       Tag data contains the INTR signal mask.  If the calling task receives a 
  1357.       signal in the INTR mask, the TermiteTCP interrupts current function calls 
  1358.       and returns with the error code EINTR.  The INTR mask defaults to the 
  1359.       CTRL-C signal (SIGBREAKF_C,bit 12).
  1360.  
  1361.    SBTC_ERRNO
  1362.       The errno value. The values are defined in <sys/errno.h>.
  1363.  
  1364.    SBTC_ERRNOLONGPTR
  1365.       Set (only) the pointer to the errno variable defined by the program.  
  1366.       TermiteTCP defines a value for this by default, but the application must 
  1367.       set the pointer with one of these tags, if it wishes to access the
  1368.       errno variable directly.
  1369.  
  1370.    SBTC_ERRNOSTRPTR
  1371.       Returns an error string pointer describing the errno value given on input. 
  1372.       This gives extended information about the last error.
  1373.  
  1374.       On call the ti_Data must contain the error code number.  On return the 
  1375.       ti_Data is assigned to the string pointer. (*ti_Data, if by reference).  
  1376.       See the file <sys/errno.h> for symbolic definitions for the errno codes.
  1377.  
  1378.    SBTC_HERRNO
  1379.       The name resolver error code value. Get this to find out why the 
  1380.       gethostbyname() or gethostbyaddr() failed. The values are defined 
  1381.       in <netdb.h>.
  1382.  
  1383.    SBTC_SIGIOMASK
  1384.       The signals specified in the mask in the tag data are sent to the calling 
  1385.       task when asynhronous I/O is to be notified. The default value is zero, 
  1386.       i.e., no signals are sent. The signals in the mask are sent whenever 
  1387.       something happens on the socket. This mechanism is compatible with the 
  1388.       Unix SIGIO signal. Since AmigaOS signals may get combined, one signal may 
  1389.       include notification for originally distinct events on the socket.
  1390.  
  1391.     SBTC_SIGURGMASK
  1392.       The signals specified in the mask in the tag data are sent to the calling 
  1393.       task when notification about urgent data arrives. The default value is 
  1394.       zero, ie. no signals are sent. This mechanism is compatible with the 
  1395.       Unix SIGURG signal.
  1396.  
  1397.       Note that this signal does not indicate the arrival of the actual 
  1398.       out-of-band data. If the receive buffer of the socket is full, the urgent 
  1399.       data can't even be received. Because of this the application may need to 
  1400.       read some normal data off the socket before it can read the urgent data.
  1401.  
  1402. RESULT
  1403.    Returns 0 on success, and a (positive) index of the failing tag on error.  
  1404.    Note that the value 1 means first TagItem, 2 the second one, etc..  
  1405.  
  1406. ****************************************************************************
  1407. WaitSelect
  1408. ****************************************************************************
  1409.  
  1410. NAME
  1411.    WaitSelect -- Examines specified sockets' read, write or exception 
  1412.                  with Exec Wait() function.
  1413.  
  1414. SYNOPSIS
  1415.    #include <sys/types.h>
  1416.    #include <sys/time.h>
  1417.      
  1418.    int WaitSelect(int nfds, fd_set *readfds, fd_set *writefds,
  1419.    D0                 D0             A0                A1
  1420.                   fd_set *exceptfds, struct timeval *timeout,
  1421.                            A2                          A3
  1422.                   ULONG *sigmask)
  1423.                           D1
  1424.  
  1425. DESCRIPTION
  1426.    WaitSelect() examines the I/O descriptor sets whose addresses are passed 
  1427.    in readfds, writefds, and exceptfds to see if some of their descriptors 
  1428.    are ready for reading, are ready for writing, or have an exceptional 
  1429.    condition pending. On return, the given descriptor sets with subsets
  1430.    consisting of those descriptors that are ready for the requested operation.
  1431.    
  1432.    Additionally, WaitSelect() takes a signal mask which is waited during normal
  1433.    select() operation. If one of these singals is received, WaitSelect() 
  1434.    returns and has re-set the signal mask to return those signals that have 
  1435.    arrived and value 0 is returned.
  1436.  
  1437.    If timeout is a non-nil pointer, it specifies a maximum interval to wait 
  1438.    for the selection to complete.  If timeout is a nil pointer, the select 
  1439.    blocks indefinitely.  To affect a poll, the timeout argument should be 
  1440.    non-nil, pointing to a zero-valued timeval structure.
  1441.  
  1442.    Any of readfds, writefds, and exceptfds may be given as NULL pointers if 
  1443.    no descriptors are of interest.
  1444.  
  1445.    Selecting true for reading on a socket descriptor upon which a listen() 
  1446.    call has been performed indicates that a subsequent accept() call on that 
  1447.    descriptor will not block.
  1448.  
  1449.    If a process is blocked on a select() waiting for input from a socket 
  1450.    and the sending process closes the socket, the select notes this as an 
  1451.    exception rather than as data.  Hence, if the select is not currently 
  1452.    looking for exceptions, it will wait forever.
  1453.  
  1454.    The descriptor masks are always modified on return, even if the call 
  1455.    returns as the result of the timeout.
  1456.  
  1457.    A common error is to use the socket number in which you are interested 
  1458.    as the first argument. Use socket+1.
  1459.  
  1460. INPUTS
  1461.    numfds
  1462.       Maximum number of bits in the masks that represent valid 
  1463.       file descriptors.
  1464.  
  1465.    readfds
  1466.       32 bit mask representing read file descriptors
  1467.  
  1468.    writefds
  1469.       32 bit mask representing write file descriptors
  1470.  
  1471.    exceptfds
  1472.       32 bit mask representing except file descriptors
  1473.  
  1474.    timeout
  1475.       Pointer to a timeval structure which holds the maximum amount of time 
  1476.       to wait for the selection to complete.
  1477.  
  1478.  
  1479. RETURNS
  1480.    The number of ready sockets, 
  1481.    zero if a timeout occurred,
  1482.    -1 on error.
  1483.    readfds    A mask of the ready socket descriptors
  1484.    writefds   A mask of the ready socket descriptors 
  1485.    exceptfds  A mask of the ready socket descriptors
  1486.  
  1487. ERRORS
  1488.    An error return from select() indicates:
  1489.  
  1490.    EBADF
  1491.       One of the descriptor sets specified an invalid descriptor.
  1492.  
  1493.    EINTR
  1494.       A signal was delivered before the time limit expired and before any 
  1495.       of the selected events occurred.
  1496.  
  1497.    EINVAL
  1498.       The specified time limit is invalid.  One of its components is negative 
  1499.       or too large.
  1500.  
  1501. SEE ALSO
  1502. accept(), connect(), recv(), send()
  1503.  
  1504.