home *** CD-ROM | disk | FTP | other *** search
/ synchro.net / synchro.net.tar / synchro.net / main / BBS / D32_01.ZIP / SOCKDEF.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-06-26  |  18.0 KB  |  543 lines

  1. unit SockDef;
  2. (*
  3. **
  4. ** SOCKDEF routines
  5. **
  6. ** Copyright (c) 1998 by Thomas W. Mueller
  7. **
  8. ** Created : 24-Oct-1998
  9. ** Last update : 24-Oct-1998
  10. **
  11. **
  12. *)
  13.  
  14. (*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-*)
  15.  INTERFACE
  16. (*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-*)
  17.  
  18. uses
  19.   Sysutils,
  20. {$IFDEF OS2}
  21.   Os2def;
  22. {$ENDIF}
  23. {$IFDEF LINUX}
  24.   Linux;
  25. {$ENDIF}
  26. {$IFDEF WIN32}
  27.   Windows;
  28. {$ENDIF}
  29.  
  30. (*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-*)
  31.  
  32. {$IFDEF VER0_99_12}
  33. type pInteger = ^Integer;
  34.      tFarProc = pointer;
  35.      SmallInt = System.Integer;
  36. {$ENDIF}
  37.  
  38. {$IFDEF LINUX}
  39. type ULONG    = longint;
  40. {$ENDIF}
  41.  
  42. type
  43.   tSockDesc  = LongInt;
  44.   SmallWord  = System.Word;
  45.  
  46. type
  47.   eSocketErr = class(Exception);
  48.  
  49. (*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-*)
  50.  
  51. const
  52.   MaxHostNameLen = 120;
  53.  
  54. (*
  55. ** Option flags per-socket.
  56. *)
  57.   SO_DEBUG        =$0001;          // turn on debugging info recording
  58.   SO_ACCEPTCONN   =$0002;          // socket has had listen()
  59.   SO_REUSEADDR    =$0004;          // allow local address reuse
  60.   SO_KEEPALIVE    =$0008;          // keep connections alive
  61.   SO_DONTROUTE    =$0010;          // just use interface addresses
  62.   SO_BROADCAST    =$0020;          // permit sending of broadcast msgs
  63.   SO_USELOOPBACK  =$0040;          // bypass hardware when possible
  64.   SO_LINGER       =$0080;          // linger on close if data present
  65.   SO_OOBINLINE    =$0100;          // leave received OOB data in line
  66.  
  67. (*
  68. ** Additional options, not kept in so_options.
  69. *)
  70.   SO_SNDBUF       =$1001;          // send buffer size
  71.   SO_RCVBUF       =$1002;          // receive buffer size
  72.   SO_SNDLOWAT     =$1003;          // send low-water mark
  73.   SO_RCVLOWAT     =$1004;          // receive low-water mark
  74.   SO_SNDTIMEO     =$1005;          // send timeout
  75.   SO_RCVTIMEO     =$1006;          // receive timeout
  76.   SO_ERROR        =$1007;          // get error status and clear
  77.   SO_TYPE         =$1008;          // get socket type
  78.  
  79. (*
  80. ** Level number for (get/set)sockopt() to apply to socket itself.
  81. *)
  82.   SOL_SOCKET      =$ffff;          // options for socket level
  83.  
  84. (*
  85. ** Address families.
  86. *)
  87.   AF_UNSPEC      =  0;              // unspecified
  88.   AF_UNIX        =  1;              // local to host (pipes, portals)
  89.   AF_INET        =  2;              // internetwork: UDP, TCP, etc.
  90.   AF_IMPLINK     =  3;              // arpanet imp addresses
  91.   AF_PUP         =  4;              // pup protocols: e.g. BSP
  92.   AF_CHAOS       =  5;              // mit CHAOS protocols
  93.   AF_NS          =  6;              // XEROX NS protocols
  94.   AF_NBS         =  7;              // nbs protocols
  95.   AF_ECMA        =  8;              // european computer manufacturers
  96.   AF_DATAKIT     =  9;              // datakit protocols
  97.   AF_CCITT       = 10;              // CCITT protocols, X.25 etc
  98.   AF_SNA         = 11;              // IBM SNA
  99.   AF_DECnet      = 12;              // DECnet
  100.   AF_DLI         = 13;              // Direct data link interface
  101.   AF_LAT         = 14;              // LAT
  102.   AF_HYLINK      = 15;              // NSC Hyperchannel
  103.   AF_APPLETALK   = 16;              // Apple Talk
  104.  
  105.   AF_OS2         = AF_UNIX;
  106.  
  107.   AF_NB          = 17;                // Netbios
  108.   AF_NETBIOS     = AF_NB;
  109.  
  110.   AF_MAX         = 18;
  111.  
  112. (*
  113. ** Protocol families, same as address families for now.
  114. *)
  115.   PF_UNSPEC       = AF_UNSPEC;
  116.   PF_UNIX         = AF_UNIX;
  117.   PF_INET         = AF_INET;
  118.   PF_IMPLINK      = AF_IMPLINK;
  119.   PF_PUP          = AF_PUP;
  120.   PF_CHAOS        = AF_CHAOS;
  121.   PF_NS           = AF_NS;
  122.   PF_NBS          = AF_NBS;
  123.   PF_ECMA         = AF_ECMA;
  124.   PF_DATAKIT      = AF_DATAKIT;
  125.   PF_CCITT        = AF_CCITT;
  126.   PF_SNA          = AF_SNA;
  127.   PF_DECnet       = AF_DECnet;
  128.   PF_DLI          = AF_DLI;
  129.   PF_LAT          = AF_LAT;
  130.   PF_HYLINK       = AF_HYLINK;
  131.   PF_APPLETALK    = AF_APPLETALK;
  132.   PF_NETBIOS      = AF_NB;
  133.   PF_NB           = AF_NB;
  134.   PF_OS2          = PF_UNIX;
  135.   PF_MAX          = AF_MAX;
  136.  
  137. (*
  138. ** Maximum queue length specifiable by listen.
  139. *)
  140.  
  141.   SOMAXCONN       = 5;
  142.  
  143.   FREAD  =1;
  144.   FWRITE =2;
  145.  
  146.   MSG_OOB         =$1;             // process out-of-band data
  147.   MSG_PEEK        =$2;             // peek at incoming message
  148.   MSG_DONTROUTE   =$4;             // send without using routing tables
  149.   MSG_FULLREAD    =$8;             // send without using routing tables
  150.  
  151.   MSG_MAXIOVLEN   =16;
  152.  
  153. const
  154. { All Windows Sockets error constants are biased by WSABASEERR from the "normal" }
  155.  
  156.   WSABASEERR              = 10000;
  157.  
  158. { Windows Sockets definitions of regular Microsoft C error constants }
  159.  
  160.   WSAEINTR                = (WSABASEERR+4);
  161.   WSAEBADF                = (WSABASEERR+9);
  162.   WSAEACCES               = (WSABASEERR+13);
  163.   WSAEFAULT               = (WSABASEERR+14);
  164.   WSAEINVAL               = (WSABASEERR+22);
  165.   WSAEMFILE               = (WSABASEERR+24);
  166.  
  167. { Windows Sockets definitions of regular Berkeley error constants }
  168.  
  169.   WSAEWOULDBLOCK          = (WSABASEERR+35);
  170.   WSAEINPROGRESS          = (WSABASEERR+36);
  171.   WSAEALREADY             = (WSABASEERR+37);
  172.   WSAENOTSOCK             = (WSABASEERR+38);
  173.   WSAEDESTADDRREQ         = (WSABASEERR+39);
  174.   WSAEMSGSIZE             = (WSABASEERR+40);
  175.   WSAEPROTOTYPE           = (WSABASEERR+41);
  176.   WSAENOPROTOOPT          = (WSABASEERR+42);
  177.   WSAEPROTONOSUPPORT      = (WSABASEERR+43);
  178.   WSAESOCKTNOSUPPORT      = (WSABASEERR+44);
  179.   WSAEOPNOTSUPP           = (WSABASEERR+45);
  180.   WSAEPFNOSUPPORT         = (WSABASEERR+46);
  181.   WSAEAFNOSUPPORT         = (WSABASEERR+47);
  182.   WSAEADDRINUSE           = (WSABASEERR+48);
  183.   WSAEADDRNOTAVAIL        = (WSABASEERR+49);
  184.   WSAENETDOWN             = (WSABASEERR+50);
  185.   WSAENETUNREACH          = (WSABASEERR+51);
  186.   WSAENETRESET            = (WSABASEERR+52);
  187.   WSAECONNABORTED         = (WSABASEERR+53);
  188.   WSAECONNRESET           = (WSABASEERR+54);
  189.   WSAENOBUFS              = (WSABASEERR+55);
  190.   WSAEISCONN              = (WSABASEERR+56);
  191.   WSAENOTCONN             = (WSABASEERR+57);
  192.   WSAESHUTDOWN            = (WSABASEERR+58);
  193.   WSAETOOMANYREFS         = (WSABASEERR+59);
  194.   WSAETIMEDOUT            = (WSABASEERR+60);
  195.   WSAECONNREFUSED         = (WSABASEERR+61);
  196.   WSAELOOP                = (WSABASEERR+62);
  197.   WSAENAMETOOLONG         = (WSABASEERR+63);
  198.   WSAEHOSTDOWN            = (WSABASEERR+64);
  199.   WSAEHOSTUNREACH         = (WSABASEERR+65);
  200.   WSAENOTEMPTY            = (WSABASEERR+66);
  201.   WSAEPROCLIM             = (WSABASEERR+67);
  202.   WSAEUSERS               = (WSABASEERR+68);
  203.   WSAEDQUOT               = (WSABASEERR+69);
  204.   WSAESTALE               = (WSABASEERR+70);
  205.   WSAEREMOTE              = (WSABASEERR+71);
  206.  
  207.   WSAEDISCON              = (WSABASEERR+101);
  208.  
  209. { Extended Windows Sockets error constant definitions }
  210.  
  211.   WSASYSNOTREADY          = (WSABASEERR+91);
  212.   WSAVERNOTSUPPORTED      = (WSABASEERR+92);
  213.   WSANOTINITIALISED       = (WSABASEERR+93);
  214.  
  215. { Error return codes from gethostbyname() and gethostbyaddr()
  216.   (when using the resolver). Note that these errors are
  217.   retrieved via WSAGetLastError() and must therefore follow
  218.   the rules for avoiding clashes with error numbers from
  219.   specific implementations or language run-time systems.
  220.   For this reason the codes are based at WSABASEERR+1001.
  221.   Note also that [WSA]NO_ADDRESS is defined only for
  222.   compatibility purposes. }
  223.  
  224. { Authoritative Answer: Host not found }
  225.  
  226.   WSAHOST_NOT_FOUND       = (WSABASEERR+1001);
  227.   HOST_NOT_FOUND          = WSAHOST_NOT_FOUND;
  228.  
  229. { Non-Authoritative: Host not found, or SERVERFAIL }
  230.  
  231.   WSATRY_AGAIN            = (WSABASEERR+1002);
  232.   TRY_AGAIN               = WSATRY_AGAIN;
  233.  
  234. { Non recoverable errors, FORMERR, REFUSED, NOTIMP }
  235.  
  236.   WSANO_RECOVERY          = (WSABASEERR+1003);
  237.   NO_RECOVERY             = WSANO_RECOVERY;
  238.  
  239. { Valid name, no data record of requested type }
  240.  
  241.   WSANO_DATA              = (WSABASEERR+1004);
  242.   NO_DATA                 = WSANO_DATA;
  243.  
  244. { no address, look for MX record }
  245.  
  246.   WSANO_ADDRESS           = WSANO_DATA;
  247.   NO_ADDRESS              = WSANO_ADDRESS;
  248.  
  249. { Windows Sockets errors redefined as regular Berkeley error constants.
  250.   These are commented out in Windows NT to avoid conflicts with errno.h.
  251.   Use the WSA constants instead. }
  252.  
  253.   EWOULDBLOCK        =  WSAEWOULDBLOCK;
  254.   EINPROGRESS        =  WSAEINPROGRESS;
  255.   EALREADY           =  WSAEALREADY;
  256.   ENOTSOCK           =  WSAENOTSOCK;
  257.   EDESTADDRREQ       =  WSAEDESTADDRREQ;
  258.   EMSGSIZE           =  WSAEMSGSIZE;
  259.   EPROTOTYPE         =  WSAEPROTOTYPE;
  260.   ENOPROTOOPT        =  WSAENOPROTOOPT;
  261.   EPROTONOSUPPORT    =  WSAEPROTONOSUPPORT;
  262.   ESOCKTNOSUPPORT    =  WSAESOCKTNOSUPPORT;
  263.   EOPNOTSUPP         =  WSAEOPNOTSUPP;
  264.   EPFNOSUPPORT       =  WSAEPFNOSUPPORT;
  265.   EAFNOSUPPORT       =  WSAEAFNOSUPPORT;
  266.   EADDRINUSE         =  WSAEADDRINUSE;
  267.   EADDRNOTAVAIL      =  WSAEADDRNOTAVAIL;
  268.   ENETDOWN           =  WSAENETDOWN;
  269.   ENETUNREACH        =  WSAENETUNREACH;
  270.   ENETRESET          =  WSAENETRESET;
  271.   ECONNABORTED       =  WSAECONNABORTED;
  272.   ECONNRESET         =  WSAECONNRESET;
  273.   ENOBUFS            =  WSAENOBUFS;
  274.   EISCONN            =  WSAEISCONN;
  275.   ENOTCONN           =  WSAENOTCONN;
  276.   ESHUTDOWN          =  WSAESHUTDOWN;
  277.   ETOOMANYREFS       =  WSAETOOMANYREFS;
  278.   ETIMEDOUT          =  WSAETIMEDOUT;
  279.   ECONNREFUSED       =  WSAECONNREFUSED;
  280.   ELOOP              =  WSAELOOP;
  281.   ENAMETOOLONG       =  WSAENAMETOOLONG;
  282.   EHOSTDOWN          =  WSAEHOSTDOWN;
  283.   EHOSTUNREACH       =  WSAEHOSTUNREACH;
  284.   ENOTEMPTY          =  WSAENOTEMPTY;
  285.   EPROCLIM           =  WSAEPROCLIM;
  286.   EUSERS             =  WSAEUSERS;
  287.   EDQUOT             =  WSAEDQUOT;
  288.   ESTALE             =  WSAESTALE;
  289.   EREMOTE            =  WSAEREMOTE;
  290.  
  291.   SockAddr_Len   = 16;
  292.   In_Addr_Len    =  4;
  293.  
  294.   InAddr_Any        =  0;
  295.   InAddr_Loopback   = $7F000001;
  296.   InAddr_Broadcast  = $FFFFFFFF;
  297.   InAddr_None       = $FFFFFFFF;
  298.  
  299.   SOCK_NULL      =  0;
  300.   SOCK_STREAM    =  1;            // stream socket
  301.   SOCK_DGRAM     =  2;            // datagram socket
  302.   SOCK_RAW       =  3;            // raw-protocol interface
  303.   SOCK_RDM       =  4;            // reliably-delivered message
  304.   SOCK_SEQPACKET =  5;            // sequenced packet stream
  305.  
  306.   IPPROTO_NULL   =  0;
  307.   IPPROTO_UP     =  17;
  308.   IPPROTO_TCP    =  6;
  309.  
  310.  
  311. const
  312.   IOCPARM_MASK = $7f;
  313.   IOC_VOID     = $20000000;
  314.   IOC_OUT      = $40000000;
  315.   IOC_IN       = $80000000;
  316.   IOC_INOUT    = (IOC_IN or IOC_OUT);
  317.  
  318.   FIONREAD     = IOC_OUT or { get # bytes to read }
  319.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  320.     (Longint(Byte('f')) shl 8) or 127;
  321.   FIONBIO      = IOC_IN or { set/clear non-blocking i/o }
  322.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  323.     (Longint(Byte('f')) shl 8) or 126;
  324.   FIOASYNC     = IOC_IN or { set/clear async i/o }
  325.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  326.     (Longint(Byte('f')) shl 8) or 125;
  327.  
  328. type
  329.   pLongInt = ^LongInt;
  330.  
  331.   pIoVec = ^tIoVec;
  332.   tIoVec = packed record
  333.     iov_base: POINTER;
  334.     iov_len: LongInt;
  335.   end;
  336.  
  337. (*
  338. ** Structure used for manipulating linger option.
  339. *)
  340.   tLinger = packed record
  341.     l_onoff: LongInt;                // option on/off
  342.     l_linger: LongInt;               // linger time
  343.   END;
  344.  
  345. (*
  346. ** Structure used by kernel to pass protocol
  347. ** information in raw sockets.
  348. *)
  349.  
  350.   tSockProto = packed record
  351.     sp_family: WORD;              // address family
  352.     sp_protocol: WORD;            // protocol
  353.   END;
  354.  
  355.   off_t = LongInt;
  356.  
  357.   tuio = packed record
  358.     uio_iov: pIoVec;
  359.     uio_iovcnt: LongInt;
  360.     uio_offset: off_t;
  361.     uio_segflg: LongInt;
  362.     uio_resid: LongInt;
  363.   END;
  364.  
  365.   pIn_Addr = ^tIn_Addr;
  366.   tIn_Addr = packed record
  367.              case integer of
  368.                0: (IPAddr:   ULong);
  369.                1: (ClassA:   byte;
  370.                    ClassB:   byte;
  371.                    ClassC:   byte;
  372.                    ClassD:   byte)
  373.              end;
  374.  
  375. (*
  376. ** Structure used by kernel to store most
  377. ** addresses.
  378. *)
  379.   pSockAddr=^tSockAddr;
  380.   tSockAddr=packed record
  381.             case integer of
  382.               0: (Sin_Family: SmallWord;
  383.                   Sin_Port:   SmallWord;
  384.                   Sin_Addr:   tIn_Addr;
  385.                   Sin_Zero:   array[1.. 8] of byte);
  386.               1: (Sa_Family:  SmallWord;
  387.                   Sa_Addr:    array[1..14] of byte);
  388.             end;
  389.  
  390. (*
  391. ** Message header for recvmsg and sendmsg calls.
  392. *)
  393.   pMsgHdr = ^tMsgHdr;
  394.   tMsgHdr = packed record
  395.     msg_name: pChar;               // optional address
  396.     msg_namelen: LongInt;            // size of address
  397.     msg_iov: pIoVec;         // scatter/gather array
  398.     msg_iovlen: LongInt;             // # elements in msg_iov
  399.     msg_accrights: pChar;          // access rights sent/received
  400.     msg_accrightslen: LongInt;
  401.   END;
  402.  
  403.   uio_rw = ( UIO_READ, UIO_WRITE );
  404.  
  405.   pHostEnt = ^tHostEnt;
  406.   tHostEnt = packed record
  407.     H_Name:      ^string;
  408.     H_Alias:     pointer;
  409. {$IFDEF OS2}
  410.     H_AddrType:  longint;
  411.     H_Length:    longint;
  412. {$ELSE}
  413.     h_addrtype: Smallint;
  414.     h_length: Smallint;
  415. {$ENDIF}
  416.     H_Addr_List: ^pIn_Addr;
  417.   END;
  418.  
  419.   pProtoEnt = ^tProtoEnt;
  420.   TProtoEnt = packed record
  421.     p_name:    pChar;     (* official protocol name *)
  422.     p_aliases: ^pChar;   (* alias list *)
  423.     p_proto:   SmallInt;       (* protocol # *)
  424.   end;
  425.  
  426.   pServEnt = ^tServEnt;
  427.   tServEnt = packed record
  428.     s_name:    pChar;        // official service name
  429.     s_aliases: ^pChar;       // alias list
  430.     s_port:    SmallInt;      // port #
  431.     s_proto:   pChar;        // protocol to use
  432.   END;
  433.  
  434. // these types are only used in windows version
  435. const
  436.   FD_SETSIZE     =   64;
  437.  
  438. type
  439.   PFDSet = ^TFDSet;
  440.   TFDSet = packed record
  441.     fd_count: ULONG;
  442.     fd_array: array[0..FD_SETSIZE-1] of ULONG;
  443.   end;
  444.  
  445.   PTimeVal = ^TTimeVal;
  446.   TTimeVal = packed record
  447.     tv_sec: Longint;
  448.     tv_usec: Longint;
  449.   end;
  450.  
  451. const
  452.   WSADESCRIPTION_LEN     =   256;
  453.   WSASYS_STATUS_LEN      =   128;
  454.  
  455. type
  456.   PWSAData = ^TWSAData;
  457.   TWSAData = packed record
  458.     wVersion: Word;
  459.     wHighVersion: Word;
  460.     szDescription: array[0..WSADESCRIPTION_LEN] of Char;
  461.     szSystemStatus: array[0..WSASYS_STATUS_LEN] of Char;
  462.     iMaxSockets: Word;
  463.     iMaxUdpDg: Word;
  464.     lpVendorInfo: PChar;
  465.   end;
  466.  
  467. (*
  468. ** The re-defination of error constants are necessary to avoid conflict with
  469. ** standard IBM C Set/2 V1.0 error constants.
  470. **
  471. ** All OS/2 SOCKET API error constants are biased by SOCBASEERR from the "normal"
  472. **
  473. *)
  474.  
  475. const
  476.   SOCBASEERR = 10000;
  477.  
  478. (*
  479. ** OS/2 SOCKET API definitions of regular Microsoft C 6.0 error constants
  480. *)
  481.  
  482. const
  483.   SOCEPERM = (SOCBASEERR+1);             (* Not owner *)
  484.   SOCESRCH = (SOCBASEERR+3);             (* No such process *)
  485.   SOCEINTR = (SOCBASEERR+4);             (* Interrupted system call *)
  486.   SOCENXIO = (SOCBASEERR+6);             (* No such device or address *)
  487.   SOCEBADF = (SOCBASEERR+9);             (* Bad file number *)
  488.   SOCEACCES = (SOCBASEERR+13);            (* Permission denied *)
  489.   SOCEFAULT = (SOCBASEERR+14);            (* Bad address *)
  490.   SOCEINVAL = (SOCBASEERR+22);            (* Invalid argument *)
  491.   SOCEMFILE = (SOCBASEERR+24);            (* Too many open files *)
  492.   SOCEPIPE = (SOCBASEERR+32);            (* Broken pipe *)
  493.  
  494.   SOCEOS2ERR = (SOCBASEERR+100);            (* OS/2 Error *)
  495.  
  496. (*
  497. ** OS/2 SOCKET API definitions of regular BSD error constants
  498. *)
  499.  
  500. const
  501.   SOCEWOULDBLOCK = (SOCBASEERR+35);            (* Operation would block *)
  502.   SOCEINPROGRESS = (SOCBASEERR+36);            (* Operation now in progress *)
  503.   SOCEALREADY = (SOCBASEERR+37);            (* Operation already in progress *)
  504.   SOCENOTSOCK = (SOCBASEERR+38);            (* Socket operation on non-socket *)
  505.   SOCEDESTADDRREQ = (SOCBASEERR+39);            (* Destination address required *)
  506.   SOCEMSGSIZE = (SOCBASEERR+40);            (* Message too long *)
  507.   SOCEPROTOTYPE = (SOCBASEERR+41);            (* Protocol wrong type for socket *)
  508.   SOCENOPROTOOPT = (SOCBASEERR+42);            (* Protocol not available *)
  509.   SOCEPROTONOSUPPORT = (SOCBASEERR+43);            (* Protocol not supported *)
  510.   SOCESOCKTNOSUPPORT = (SOCBASEERR+44);            (* Socket type not supported *)
  511.   SOCEOPNOTSUPP = (SOCBASEERR+45);            (* Operation not supported on socket *)
  512.   SOCEPFNOSUPPORT = (SOCBASEERR+46);            (* Protocol family not supported *)
  513.   SOCEAFNOSUPPORT = (SOCBASEERR+47);            (* Address family not supported by protocol family *)
  514.   SOCEADDRINUSE = (SOCBASEERR+48);            (* Address already in use *)
  515.   SOCEADDRNOTAVAIL = (SOCBASEERR+49);            (* Can't assign requested address *)
  516.   SOCENETDOWN = (SOCBASEERR+50);            (* Network is down *)
  517.   SOCENETUNREACH = (SOCBASEERR+51);            (* Network is unreachable *)
  518.   SOCENETRESET = (SOCBASEERR+52);            (* Network dropped connection on reset *)
  519.   SOCECONNABORTED = (SOCBASEERR+53);            (* Software caused connection abort *)
  520.   SOCECONNRESET = (SOCBASEERR+54);            (* Connection reset by peer *)
  521.   SOCENOBUFS = (SOCBASEERR+55);            (* No buffer space available *)
  522.   SOCEISCONN = (SOCBASEERR+56);            (* Socket is already connected *)
  523.   SOCENOTCONN = (SOCBASEERR+57);            (* Socket is not connected *)
  524.   SOCESHUTDOWN = (SOCBASEERR+58);            (* Can't send after socket shutdown *)
  525.   SOCETOOMANYREFS = (SOCBASEERR+59);            (* Too many references: can't splice *)
  526.   SOCETIMEDOUT = (SOCBASEERR+60);            (* Connection timed out *)
  527.   SOCECONNREFUSED = (SOCBASEERR+61);            (* Connection refused *)
  528.   SOCELOOP = (SOCBASEERR+62);            (* Too many levels of symbolic links *)
  529.   SOCENAMETOOLONG = (SOCBASEERR+63);            (* File name too long *)
  530.   SOCEHOSTDOWN = (SOCBASEERR+64);            (* Host is down *)
  531.   SOCEHOSTUNREACH = (SOCBASEERR+65);            (* No route to host *)
  532.   SOCENOTEMPTY = (SOCBASEERR+66);            (* Directory not empty *)
  533.  
  534. (*
  535. ** OS/2 SOCKET API errors redefined as regular BSD error constants
  536. *)
  537.  
  538. (*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-*)
  539.  IMPLEMENTATION
  540. (*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-*)
  541.  
  542. end. { unit SockDef }
  543.