home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sibdemo3.zip / SOURCE.DAT / SOURCE / RTL / SOCKAPI.PAS < prev    next >
Pascal/Delphi Source File  |  1997-08-11  |  8KB  |  226 lines

  1. UNIT SockApi;
  2.  
  3. INTERFACE
  4.  
  5. CONST
  6.      SOCK_STREAM     =1;               /* stream socket */
  7.      SOCK_DGRAM      =2;               /* datagram socket */
  8.      SOCK_RAW        =3;               /* raw-protocol interface */
  9.      SOCK_RDM        =4;               /* reliably-delivered message */
  10.      SOCK_SEQPACKET  =5;               /* sequenced packet stream */
  11.  
  12. /*
  13.  * Option flags per-socket.
  14.  */
  15.      SO_DEBUG        =$0001;          /* turn on debugging info recording */
  16.      SO_ACCEPTCONN   =$0002;          /* socket has had listen() */
  17.      SO_REUSEADDR    =$0004;          /* allow local address reuse */
  18.      SO_KEEPALIVE    =$0008;          /* keep connections alive */
  19.      SO_DONTROUTE    =$0010;          /* just use interface addresses */
  20.      SO_BROADCAST    =$0020;          /* permit sending of broadcast msgs */
  21.      SO_USELOOPBACK  =$0040;          /* bypass hardware when possible */
  22.      SO_LINGER       =$0080;          /* linger on close if data present */
  23.      SO_OOBINLINE    =$0100;          /* leave received OOB data in line */
  24.  
  25. /*
  26.  * Additional options, not kept in so_options.
  27.  */
  28.      SO_SNDBUF       =$1001;          /* send buffer size */
  29.      SO_RCVBUF       =$1002;          /* receive buffer size */
  30.      SO_SNDLOWAT     =$1003;          /* send low-water mark */
  31.      SO_RCVLOWAT     =$1004;          /* receive low-water mark */
  32.      SO_SNDTIMEO     =$1005;          /* send timeout */
  33.      SO_RCVTIMEO     =$1006;          /* receive timeout */
  34.      SO_ERROR        =$1007;          /* get error status and clear */
  35.      SO_TYPE         =$1008;          /* get socket type */
  36.  
  37. /*
  38.  * Structure used for manipulating linger option.
  39.  */
  40. TYPE
  41.     linger=RECORD
  42.                  l_onoff:LONGINT;                /* option on/off */
  43.                  l_linger:LONGINT;               /* linger time */
  44.     END;
  45.  
  46. /*
  47.  * Level number for (get/set)sockopt() to apply to socket itself.
  48.  */
  49. CONST
  50.      SOL_SOCKET      =$ffff;          /* options for socket level */
  51.  
  52. /*
  53.  * Address families.
  54.  */
  55. CONST
  56.      AF_UNSPEC       =0;               /* unspecified */
  57.      AF_UNIX         =1;               /* local to host (pipes, portals) */
  58.      AF_INET         =2;               /* internetwork: UDP, TCP, etc. */
  59.      AF_IMPLINK      =3;               /* arpanet imp addresses */
  60.      AF_PUP          =4;               /* pup protocols: e.g. BSP */
  61.      AF_CHAOS        =5;               /* mit CHAOS protocols */
  62.      AF_NS           =6;               /* XEROX NS protocols */
  63.      AF_NBS          =7;               /* nbs protocols */
  64.      AF_ECMA         =8;               /* european computer manufacturers */
  65.      AF_DATAKIT      =9;               /* datakit protocols */
  66.      AF_CCITT        =10;              /* CCITT protocols, X.25 etc */
  67.      AF_SNA          =11;              /* IBM SNA */
  68.      AF_DECnet       =12;              /* DECnet */
  69.      AF_DLI          =13;              /* Direct data link interface */
  70.      AF_LAT          =14;              /* LAT */
  71.      AF_HYLINK       =15;              /* NSC Hyperchannel */
  72.      AF_APPLETALK    =16;              /* Apple Talk */
  73.  
  74.      AF_MAX          =17;
  75.  
  76. /*
  77.  * Structure used by kernel to store most
  78.  * addresses.
  79.  */
  80. TYPE
  81.     sockaddr=RECORD
  82.                    sa_family:WORD;              /* address family */
  83.                    sa_data:CSTRING[13];         /* up to 14 bytes of direct address */
  84.     END;
  85.  
  86. /*
  87.  * Structure used by kernel to pass protocol
  88.  * information in raw sockets.
  89.  */
  90.     sockproto=RECORD
  91.                     sp_family:WORD;              /* address family */
  92.                     sp_protocol:WORD;            /* protocol */
  93.     END;
  94.  
  95. /*
  96.  * Protocol families, same as address families for now.
  97.  */
  98. CONST
  99.      PF_UNSPEC       =AF_UNSPEC;
  100.      PF_UNIX         =AF_UNIX;
  101.      PF_INET         =AF_INET;
  102.      PF_IMPLINK      =AF_IMPLINK;
  103.      PF_PUP          =AF_PUP;
  104.      PF_CHAOS        =AF_CHAOS;
  105.      PF_NS           =AF_NS;
  106.      PF_NBS          =AF_NBS;
  107.      PF_ECMA         =AF_ECMA;
  108.      PF_DATAKIT      =AF_DATAKIT;
  109.      PF_CCITT        =AF_CCITT;
  110.      PF_SNA          =AF_SNA;
  111.      PF_DECnet       =AF_DECnet;
  112.      PF_DLI          =AF_DLI;
  113.      PF_LAT          =AF_LAT;
  114.      PF_HYLINK       =AF_HYLINK;
  115.      PF_APPLETALK    =AF_APPLETALK;
  116.  
  117.      PF_MAX          =AF_MAX;
  118.  
  119. /*
  120.  * Maximum queue length specifiable by listen.
  121.  */
  122.      SOMAXCONN       =5;
  123.  
  124. /*
  125.  * Message header for recvmsg and sendmsg calls.
  126.  */
  127. TYPE
  128.     iovec=RECORD
  129.                 iov_base:PChar;
  130.                 iov_len:LONGINT;
  131.     END;
  132.  
  133.     uio=RECORD
  134.               uio_iov:^iovec;
  135.               uio_iovcnt:LONGINT;
  136.               uio_offset:LONGINT;
  137.               uio_segflg:LONGINT;
  138.               uio_resid:LONGINT;
  139.     END;
  140.  
  141.     uio_rw =(UIO_READ, UIO_WRITE );
  142.  
  143.     msghdr=RECORD
  144.                  msg_name:PChar;               /* optional address */
  145.                  msg_namelen:LONGINT;          /* size of address */
  146.                  msg_iov:^iovec;               /* scatter/gather array */
  147.                  msg_iovlen:LONGINT;           /* # elements in msg_iov */
  148.                  msg_accrights:PChar;          /* access rights sent/received */
  149.                  msg_accrightslen:LONGINT;
  150.     END;
  151.  
  152. CONST
  153.      FREAD  =1;
  154.      FWRITE =2;
  155.  
  156.      MSG_OOB         =$1;             /* process out-of-band data */
  157.      MSG_PEEK        =$2;             /* peek at incoming message */
  158.      MSG_DONTROUTE   =$4;             /* send without using routing tables */
  159.  
  160.      MSG_MAXIOVLEN   =16;
  161.  
  162. IMPORTS
  163.  
  164. FUNCTION accept( p1:LONGINT;VAR sa:sockaddr;var p2:LONGINT):LONGINT;
  165.          APIENTRY; 'SO32DLL' index 1;
  166. FUNCTION bind( p1:LONGINT;VAR sa:sockaddr;p2:LONGINT):LONGINT;
  167.          APIENTRY; 'SO32DLL' index 2;
  168. FUNCTION connect( p1:LONGINT;VAR sa:sockaddr;p2:LONGINT ):LONGINT;
  169.          APIENTRY; 'SO32DLL' index 3;
  170. FUNCTION gethostid:LONGINT;
  171.          APIENTRY; 'SO32DLL' index 4;
  172. FUNCTION getpeername(p1:LONGINT;VAR sa:sockaddr;VAR p2:LONGINT):LONGINT;
  173.          APIENTRY; 'SO32DLL' index 5;
  174. FUNCTION getsockname(p1:LONGINT;VAR sa:sockaddr;VAR p2:LONGINT):LONGINT;
  175.          APIENTRY; 'SO32DLL' index 6;
  176. FUNCTION getsockopt(p1,p2,p3:LONGINT;VAR c:CSTRING;VAR p4:LONGINT):LONGINT;
  177.          APIENTRY; 'SO32DLL' index 7;
  178. FUNCTION ioctl(p1,p2:LONGINT;VAR c:CSTRING;p3:LONGINT):LONGINT;
  179.          APIENTRY; 'SO32DLL' index 8;
  180. FUNCTION listen(p1,p2:LONGINT):LONGINT;
  181.          APIENTRY; 'SO32DLL' index 9;
  182. FUNCTION recvmsg(p1:LONGINT;VAR mh:msghdr;p2:LONGINT):LONGINT;
  183.          APIENTRY; 'SO32DLL' index 21;
  184. FUNCTION recv( p1:LONGINT;VAR c:CSTRING;p2,p3:LONGINT ):LONGINT;
  185.          APIENTRY; 'SO32DLL' index 10;
  186. FUNCTION recvfrom(p1:LONGINT;VAR c:CSTRING;p2,p3:LONGINT;VAR sa:sockaddr;VAR p4:LONGINT):LONGINT;
  187.          APIENTRY; 'SO32DLL' index 11;
  188. FUNCTION select(VAR p1:LONGINT;p2,p3,p4,p5:LONGINT):LONGINT;
  189.          APIENTRY; 'SO32DLL' index 12;
  190. FUNCTION send(p1:LONGINT;VAR c:CSTRING;p2,p3:LONGINT):LONGINT;
  191.          APIENTRY; 'SO32DLL' index 13;
  192. FUNCTION sendmsg(p1:LONGINT;VAR mh:msghdr;p2:LONGINT):LONGINT;
  193.          APIENTRY; 'SO32DLL' index 22;
  194. FUNCTION sendto(p1:LONGINT;VAR c:CSTRING;p2,p3:LONGINT;VAR sa:sockaddr;p4:LONGINT):LONGINT;
  195.          APIENTRY; 'SO32DLL' index 14;
  196. FUNCTION setsockopt(p1,p2,p3:LONGINT;VAR c:CSTRING;p4:LONGINT):LONGINT;
  197.          APIENTRY; 'SO32DLL' index 15;
  198. FUNCTION sock_init:LONGINT;
  199.          APIENTRY; 'SO32DLL' index 26;
  200. FUNCTION sock_errno:LONGINT;
  201.          APIENTRY; 'SO32DLL' index 20;
  202. FUNCTION psock_errno(CONST c:CSTRING):LONGINT;
  203.          APIENTRY; 'SO32DLL' index 30;
  204. FUNCTION socket(p1,p2,p3:LONGINT):LONGINT;
  205.          APIENTRY; 'SO32DLL' index 16;
  206. FUNCTION soclose( p1:LONGINT ):LONGINT;
  207.          APIENTRY; 'SO32DLL' index 17;
  208. FUNCTION soabort(p1:LONGINT):LONGINT;
  209.          APIENTRY; 'SO32DLL' index 19;
  210. FUNCTION so_cancel(p1:LONGINT):LONGINT;
  211.          APIENTRY; 'SO32DLL' index 18;
  212. FUNCTION readv(p1:LONGINT;VAR io:iovec;p2:LONGINT):LONGINT;
  213.          APIENTRY; 'SO32DLL' index 23;
  214. FUNCTION writev(p1:LONGINT;VAR io:iovec;p2:LONGINT):LONGINT;
  215.          APIENTRY; 'SO32DLL' index 24;
  216. FUNCTION shutdown(p1,p2:LONGINT):LONGINT;
  217.          APIENTRY; 'SO32DLL' index 25;
  218. FUNCTION getinetversion(VAR c:CSTRING):LONGINT;
  219.          APIENTRY; 'SO32DLL' index 31;
  220. END;
  221.  
  222. IMPLEMENTATION
  223.  
  224. BEGIN
  225. END.
  226.