home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 August / VPR9608A.BIN / del20try / install / data.z / WINSOCK.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-08  |  25KB  |  697 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Runtime Library                          }
  5. {       Windows 32bit API Interface Unit                }
  6. {                                                       }
  7. {       Copyright (c) 1996 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit WinSock;
  12.  
  13. interface
  14.  
  15. uses Windows;
  16.  
  17. type
  18.   u_char = Char;
  19.   u_short = Word;
  20.   u_int = Integer;
  21.   u_long = Longint;
  22.  
  23. { The new type to be used in all
  24.   instances which refer to sockets. }
  25.   TSocket = u_int;
  26.  
  27. const
  28.   FD_SETSIZE     =   64;
  29.  
  30. type
  31.   PFDSet = ^TFDSet;
  32.   TFDSet = packed record
  33.     fd_count: u_int;
  34.     fd_array: array[0..FD_SETSIZE-1] of TSocket;
  35.   end;
  36.  
  37.   PTimeVal = ^TTimeVal;
  38.   TTimeVal = packed record
  39.     tv_sec: Longint;
  40.     tv_usec: Longint;
  41.   end;
  42.  
  43. const
  44.   IOCPARM_MASK = $7f;
  45.   IOC_VOID     = $20000000;
  46.   IOC_OUT      = $40000000;
  47.   IOC_IN       = $80000000;
  48.   IOC_INOUT    = (IOC_IN or IOC_OUT);
  49.  
  50.   FIONREAD     = IOC_OUT or { get # bytes to read }
  51.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  52.     (Longint(Byte('f')) shl 8) or 127;
  53.   FIONBIO      = IOC_IN or { set/clear non-blocking i/o }
  54.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  55.     (Longint(Byte('f')) shl 8) or 126;
  56.   FIOASYNC     = IOC_IN or { set/clear async i/o }
  57.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  58.     (Longint(Byte('f')) shl 8) or 125;
  59.  
  60. type
  61.   PHostEnt = ^THostEnt;
  62.   THostEnt = packed record
  63.     h_name: PChar;
  64.     h_aliases: ^PChar;
  65.     h_addrtype: Smallint;
  66.     h_length: Smallint;
  67.     h_addr_list: ^PChar;
  68.   end;
  69.  
  70.   PNetEnt = ^TNetEnt;
  71.   TNetEnt = packed record
  72.     n_name: PChar;
  73.     n_aliases: ^PChar;
  74.     n_addrtype: Smallint;
  75.     n_net: u_long;
  76.   end;
  77.  
  78.   PServEnt = ^TServEnt;
  79.   TServEnt = packed record
  80.     s_name: PChar;
  81.     s_aliases: ^PChar;
  82.     s_port: Smallint;
  83.     s_proto: PChar;
  84.   end;
  85.  
  86.   PProtoEnt = ^TProtoEnt;
  87.   TProtoEnt = packed record
  88.     p_name: PChar;
  89.     p_aliases: ^Pchar;
  90.     p_proto: Smallint;
  91.   end;
  92.  
  93. const
  94.  
  95. { Protocols }
  96.  
  97.   IPPROTO_IP     =   0;
  98.   IPPROTO_ICMP   =   1;
  99.   IPPROTO_GGP    =   2;
  100.   IPPROTO_TCP    =   6;
  101.   IPPROTO_PUP    =   12;
  102.   IPPROTO_UDP    =   17;
  103.   IPPROTO_IDP    =   22;
  104.   IPPROTO_ND     =   77;
  105.   
  106.   IPPROTO_RAW    =   255;
  107.   IPPROTO_MAX    =   256;
  108.  
  109. { Port/socket numbers: network standard functions}
  110.  
  111.   IPPORT_ECHO    =   7;
  112.   IPPORT_DISCARD =   9;
  113.   IPPORT_SYSTAT  =   11;
  114.   IPPORT_DAYTIME =   13;
  115.   IPPORT_NETSTAT =   15;
  116.   IPPORT_FTP     =   21;
  117.   IPPORT_TELNET  =   23;
  118.   IPPORT_SMTP    =   25;
  119.   IPPORT_TIMESERVER  =  37;
  120.   IPPORT_NAMESERVER  =  42;
  121.   IPPORT_WHOIS       =  43;
  122.   IPPORT_MTP         =  57;
  123.  
  124. { Port/socket numbers: host specific functions }
  125.  
  126.   IPPORT_TFTP        =  69;
  127.   IPPORT_RJE         =  77;
  128.   IPPORT_FINGER      =  79;
  129.   IPPORT_TTYLINK     =  87;
  130.   IPPORT_SUPDUP      =  95;
  131.  
  132. { UNIX TCP sockets }
  133.   
  134.   IPPORT_EXECSERVER  =  512;
  135.   IPPORT_LOGINSERVER =  513;
  136.   IPPORT_CMDSERVER   =  514;
  137.   IPPORT_EFSSERVER   =  520;
  138.   
  139. { UNIX UDP sockets }
  140.  
  141.   IPPORT_BIFFUDP     =  512;
  142.   IPPORT_WHOSERVER   =  513;
  143.   IPPORT_ROUTESERVER =  520;
  144.   
  145. { Ports < IPPORT_RESERVED are reserved for
  146.   privileged processes (e.g. root). }
  147.  
  148.   IPPORT_RESERVED    =  1024;
  149.   
  150. { Link numbers }
  151.  
  152.   IMPLINK_IP         =  155;
  153.   IMPLINK_LOWEXPER   =  156;
  154.   IMPLINK_HIGHEXPER  =  158;
  155.  
  156. type
  157.   SunB = packed record
  158.     s_b1, s_b2, s_b3, s_b4: u_char;
  159.   end;
  160.  
  161.   SunW = packed record
  162.     s_w1, s_w2: u_short;
  163.   end;
  164.  
  165.   PInAddr = ^TInAddr;
  166.   TInAddr = packed record
  167.     case integer of
  168.       0: (S_un_b: SunB);
  169.       1: (S_un_w: SunW);
  170.       2: (S_addr: u_long);
  171.   end;
  172.  
  173.   PSockAddrIn = ^TSockAddrIn;
  174.   TSockAddrIn = packed record
  175.     case Integer of
  176.       0: (sin_family: u_short;
  177.           sin_port: u_short;
  178.           sin_addr: TInAddr;
  179.           sin_zero: array[0..7] of Char);
  180.       1: (sa_family: u_short;
  181.           sa_data: array[0..13] of Char)
  182.   end;
  183.  
  184. const
  185.   INADDR_ANY       = $00000000;
  186.   INADDR_LOOPBACK  = $7F000001;
  187.   INADDR_BROADCAST = $FFFFFFFF;
  188.   INADDR_NONE      = $FFFFFFFF;
  189.  
  190. const
  191.   WSADESCRIPTION_LEN     =   256;
  192.   WSASYS_STATUS_LEN      =   128;
  193.  
  194. type
  195.   PWSAData = ^TWSAData;
  196.   TWSAData = packed record
  197.     wVersion: Word;
  198.     wHighVersion: Word;
  199.     szDescription: array[0..WSADESCRIPTION_LEN] of Char;
  200.     szSystemStatus: array[0..WSASYS_STATUS_LEN] of Char;
  201.     iMaxSockets: Word;
  202.     iMaxUdpDg: Word;
  203.     lpVendorInfo: PChar;
  204.   end;
  205.  
  206.   PTransmitFileBuffers = ^TTransmitFileBuffers;
  207.   TTransmitFileBuffers = packed record
  208.       Head: Pointer;
  209.       HeadLength: DWORD;
  210.       Tail: Pointer;
  211.       TailLength: DWORD;
  212.   end;
  213.  
  214. const
  215.  
  216. { Options for use with [gs]etsockopt at the IP level. }
  217.  
  218.   IP_OPTIONS          = 1;
  219.   IP_MULTICAST_IF     = 2;           { set/get IP multicast interface   }
  220.   IP_MULTICAST_TTL    = 3;           { set/get IP multicast timetolive  }
  221.   IP_MULTICAST_LOOP   = 4;           { set/get IP multicast loopback    }
  222.   IP_ADD_MEMBERSHIP   = 5;           { add  an IP group membership      }
  223.   IP_DROP_MEMBERSHIP  = 6;           { drop an IP group membership      }
  224.  
  225.   IP_DEFAULT_MULTICAST_TTL   = 1;    { normally limit m'casts to 1 hop  }
  226.   IP_DEFAULT_MULTICAST_LOOP  = 1;    { normally hear sends if a member  }
  227.   IP_MAX_MEMBERSHIPS         = 20;   { per socket; must fit in one mbuf }
  228.  
  229. { This is used instead of -1, since the
  230.   TSocket type is unsigned.}
  231.  
  232.   INVALID_SOCKET        = TSocket(NOT(0));
  233.   SOCKET_ERROR            = -1;
  234.  
  235. { Types }
  236.  
  237.   SOCK_STREAM     = 1;               { stream socket }
  238.   SOCK_DGRAM      = 2;               { datagram socket }
  239.   SOCK_RAW        = 3;               { raw-protocol interface }
  240.   SOCK_RDM        = 4;               { reliably-delivered message }
  241.   SOCK_SEQPACKET  = 5;               { sequenced packet stream }
  242.  
  243. { Option flags per-socket. }
  244.  
  245.   SO_DEBUG        = $0001;          { turn on debugging info recording }
  246.   SO_ACCEPTCONN   = $0002;          { socket has had listen() }
  247.   SO_REUSEADDR    = $0004;          { allow local address reuse }
  248.   SO_KEEPALIVE    = $0008;          { keep connections alive }
  249.   SO_DONTROUTE    = $0010;          { just use interface addresses }
  250.   SO_BROADCAST    = $0020;          { permit sending of broadcast msgs }
  251.   SO_USELOOPBACK  = $0040;          { bypass hardware when possible }
  252.   SO_LINGER       = $0080;          { linger on close if data present }
  253.   SO_OOBINLINE    = $0100;          { leave received OOB data in line }
  254.  
  255.   SO_DONTLINGER  =   $ff7f;
  256.  
  257. { Additional options. }
  258.  
  259.   SO_SNDBUF       = $1001;          { send buffer size }
  260.   SO_RCVBUF       = $1002;          { receive buffer size }
  261.   SO_SNDLOWAT     = $1003;          { send low-water mark }
  262.   SO_RCVLOWAT     = $1004;          { receive low-water mark }
  263.   SO_SNDTIMEO     = $1005;          { send timeout }
  264.   SO_RCVTIMEO     = $1006;          { receive timeout }
  265.   SO_ERROR        = $1007;          { get error status and clear }
  266.   SO_TYPE         = $1008;          { get socket type }
  267.  
  268. { Options for connect and disconnect data and options.  Used only by
  269.   non-TCP/IP transports such as DECNet, OSI TP4, etc. }
  270.  
  271.   SO_CONNDATA     = $7000;
  272.   SO_CONNOPT      = $7001;
  273.   SO_DISCDATA     = $7002;
  274.   SO_DISCOPT      = $7003;
  275.   SO_CONNDATALEN  = $7004;
  276.   SO_CONNOPTLEN   = $7005;
  277.   SO_DISCDATALEN  = $7006;
  278.   SO_DISCOPTLEN   = $7007;
  279.  
  280. { Option for opening sockets for synchronous access. }
  281.  
  282.   SO_OPENTYPE     = $7008;
  283.  
  284.   SO_SYNCHRONOUS_ALERT    = $10;
  285.   SO_SYNCHRONOUS_NONALERT = $20;
  286.  
  287. { Other NT-specific options. }
  288.  
  289.   SO_MAXDG        = $7009;
  290.   SO_MAXPATHDG    = $700A;
  291.  
  292. { TCP options. }
  293.  
  294.   TCP_NODELAY     = $0001;
  295.   TCP_BSDURGENT   = $7000;
  296.  
  297. { Address families. }
  298.  
  299.   AF_UNSPEC       = 0;               { unspecified }
  300.   AF_UNIX         = 1;               { local to host (pipes, portals) }
  301.   AF_INET         = 2;               { internetwork: UDP, TCP, etc. }
  302.   AF_IMPLINK      = 3;               { arpanet imp addresses }
  303.   AF_PUP          = 4;               { pup protocols: e.g. BSP }
  304.   AF_CHAOS        = 5;               { mit CHAOS protocols }
  305.   AF_IPX          = 6;               { IPX and SPX }
  306.   AF_NS           = 6;               { XEROX NS protocols }
  307.   AF_ISO          = 7;               { ISO protocols }
  308.   AF_OSI          = AF_ISO;          { OSI is ISO }
  309.   AF_ECMA         = 8;               { european computer manufacturers }
  310.   AF_DATAKIT      = 9;               { datakit protocols }
  311.   AF_CCITT        = 10;              { CCITT protocols, X.25 etc }
  312.   AF_SNA          = 11;              { IBM SNA }
  313.   AF_DECnet       = 12;              { DECnet }
  314.   AF_DLI          = 13;              { Direct data link interface }
  315.   AF_LAT          = 14;              { LAT }
  316.   AF_HYLINK       = 15;              { NSC Hyperchannel }
  317.   AF_APPLETALK    = 16;              { AppleTalk }
  318.   AF_NETBIOS      = 17;              { NetBios-style addresses }
  319.   AF_VOICEVIEW    = 18;              { VoiceView }
  320.  
  321.   AF_MAX          = 19;
  322.  
  323. type
  324.   { Structure used by kernel to store most addresses. }
  325.  
  326.   PSockAddr = ^TSockAddr;
  327.   TSockAddr = TSockAddrIn;
  328.  
  329.   { Structure used by kernel to pass protocol information in raw sockets. }
  330.   PSockProto = ^TSockProto;
  331.   TSockProto = packed record
  332.     sp_family: u_short;
  333.     sp_protocol: u_short;
  334.   end;
  335.  
  336. const
  337. { Protocol families, same as address families for now. }
  338.  
  339.   PF_UNSPEC       = AF_UNSPEC;
  340.   PF_UNIX         = AF_UNIX;
  341.   PF_INET         = AF_INET;
  342.   PF_IMPLINK      = AF_IMPLINK;
  343.   PF_PUP          = AF_PUP;
  344.   PF_CHAOS        = AF_CHAOS;
  345.   PF_NS           = AF_NS;
  346.   PF_IPX          = AF_IPX;
  347.   PF_ISO          = AF_ISO;
  348.   PF_OSI          = AF_OSI;
  349.   PF_ECMA         = AF_ECMA;
  350.   PF_DATAKIT      = AF_DATAKIT;
  351.   PF_CCITT        = AF_CCITT;
  352.   PF_SNA          = AF_SNA;
  353.   PF_DECnet       = AF_DECnet;
  354.   PF_DLI          = AF_DLI;
  355.   PF_LAT          = AF_LAT;
  356.   PF_HYLINK       = AF_HYLINK;
  357.   PF_APPLETALK    = AF_APPLETALK;
  358.   PF_VOICEVIEW    = AF_VOICEVIEW;
  359.  
  360.   PF_MAX          = AF_MAX;
  361.  
  362. type
  363. { Structure used for manipulating linger option. }
  364.   PLinger = ^TLinger;
  365.   TLinger = packed record
  366.     l_onoff: u_short;
  367.     l_linger: u_short;
  368.   end;
  369.  
  370. const
  371. { Level number for (get/set)sockopt() to apply to socket itself. }
  372.  
  373.   SOL_SOCKET      = $ffff;          {options for socket level }
  374.  
  375. { Maximum queue length specifiable by listen. }
  376.  
  377.   SOMAXCONN       = 5;
  378.  
  379.   MSG_OOB         = $1;             {process out-of-band data }
  380.   MSG_PEEK        = $2;             {peek at incoming message }
  381.   MSG_DONTROUTE   = $4;             {send without using routing tables }
  382.  
  383.   MSG_MAXIOVLEN   = 16;
  384.  
  385.   MSG_PARTIAL     = $8000;          {partial send or recv for message xport }
  386.  
  387. { Define constant based on rfc883, used by gethostbyxxxx() calls. }
  388.  
  389.   MAXGETHOSTSTRUCT        = 1024;
  390.  
  391. { Define flags to be used with the WSAAsyncSelect() call. }
  392.  
  393.   FD_READ         = $01;
  394.   FD_WRITE        = $02;
  395.   FD_OOB          = $04;
  396.   FD_ACCEPT       = $08;
  397.   FD_CONNECT      = $10;
  398.   FD_CLOSE        = $20;
  399.  
  400. { All Windows Sockets error constants are biased by WSABASEERR from the "normal" }
  401.  
  402.   WSABASEERR              = 10000;
  403.  
  404. { Windows Sockets definitions of regular Microsoft C error constants }
  405.  
  406.   WSAEINTR                = (WSABASEERR+4);
  407.   WSAEBADF                = (WSABASEERR+9);
  408.   WSAEACCES               = (WSABASEERR+13);
  409.   WSAEFAULT               = (WSABASEERR+14);
  410.   WSAEINVAL               = (WSABASEERR+22);
  411.   WSAEMFILE               = (WSABASEERR+24);
  412.  
  413. { Windows Sockets definitions of regular Berkeley error constants }
  414.  
  415.   WSAEWOULDBLOCK          = (WSABASEERR+35);
  416.   WSAEINPROGRESS          = (WSABASEERR+36);
  417.   WSAEALREADY             = (WSABASEERR+37);
  418.   WSAENOTSOCK             = (WSABASEERR+38);
  419.   WSAEDESTADDRREQ         = (WSABASEERR+39);
  420.   WSAEMSGSIZE             = (WSABASEERR+40);
  421.   WSAEPROTOTYPE           = (WSABASEERR+41);
  422.   WSAENOPROTOOPT          = (WSABASEERR+42);
  423.   WSAEPROTONOSUPPORT      = (WSABASEERR+43);
  424.   WSAESOCKTNOSUPPORT      = (WSABASEERR+44);
  425.   WSAEOPNOTSUPP           = (WSABASEERR+45);
  426.   WSAEPFNOSUPPORT         = (WSABASEERR+46);
  427.   WSAEAFNOSUPPORT         = (WSABASEERR+47);
  428.   WSAEADDRINUSE           = (WSABASEERR+48);
  429.   WSAEADDRNOTAVAIL        = (WSABASEERR+49);
  430.   WSAENETDOWN             = (WSABASEERR+50);
  431.   WSAENETUNREACH          = (WSABASEERR+51);
  432.   WSAENETRESET            = (WSABASEERR+52);
  433.   WSAECONNABORTED         = (WSABASEERR+53);
  434.   WSAECONNRESET           = (WSABASEERR+54);
  435.   WSAENOBUFS              = (WSABASEERR+55);
  436.   WSAEISCONN              = (WSABASEERR+56);
  437.   WSAENOTCONN             = (WSABASEERR+57);
  438.   WSAESHUTDOWN            = (WSABASEERR+58);
  439.   WSAETOOMANYREFS         = (WSABASEERR+59);
  440.   WSAETIMEDOUT            = (WSABASEERR+60);
  441.   WSAECONNREFUSED         = (WSABASEERR+61);
  442.   WSAELOOP                = (WSABASEERR+62);
  443.   WSAENAMETOOLONG         = (WSABASEERR+63);
  444.   WSAEHOSTDOWN            = (WSABASEERR+64);
  445.   WSAEHOSTUNREACH         = (WSABASEERR+65);
  446.   WSAENOTEMPTY            = (WSABASEERR+66);
  447.   WSAEPROCLIM             = (WSABASEERR+67);
  448.   WSAEUSERS               = (WSABASEERR+68);
  449.   WSAEDQUOT               = (WSABASEERR+69);
  450.   WSAESTALE               = (WSABASEERR+70);
  451.   WSAEREMOTE              = (WSABASEERR+71);
  452.  
  453.   WSAEDISCON              = (WSABASEERR+101);
  454.  
  455. { Extended Windows Sockets error constant definitions }
  456.  
  457.   WSASYSNOTREADY          = (WSABASEERR+91);
  458.   WSAVERNOTSUPPORTED      = (WSABASEERR+92);
  459.   WSANOTINITIALISED       = (WSABASEERR+93);
  460.  
  461. { Error return codes from gethostbyname() and gethostbyaddr()
  462.   (when using the resolver). Note that these errors are
  463.   retrieved via WSAGetLastError() and must therefore follow
  464.   the rules for avoiding clashes with error numbers from
  465.   specific implementations or language run-time systems.
  466.   For this reason the codes are based at WSABASEERR+1001.
  467.   Note also that [WSA]NO_ADDRESS is defined only for
  468.   compatibility purposes. }
  469.  
  470. { Authoritative Answer: Host not found }
  471.  
  472.   WSAHOST_NOT_FOUND       = (WSABASEERR+1001);
  473.   HOST_NOT_FOUND          = WSAHOST_NOT_FOUND;
  474.  
  475. { Non-Authoritative: Host not found, or SERVERFAIL }
  476.  
  477.   WSATRY_AGAIN            = (WSABASEERR+1002);
  478.   TRY_AGAIN               = WSATRY_AGAIN;
  479.  
  480. { Non recoverable errors, FORMERR, REFUSED, NOTIMP }
  481.  
  482.   WSANO_RECOVERY          = (WSABASEERR+1003);
  483.   NO_RECOVERY             = WSANO_RECOVERY;
  484.  
  485. { Valid name, no data record of requested type }
  486.  
  487.   WSANO_DATA              = (WSABASEERR+1004);
  488.   NO_DATA                 = WSANO_DATA;
  489.  
  490. { no address, look for MX record }
  491.  
  492.   WSANO_ADDRESS           = WSANO_DATA;
  493.   NO_ADDRESS              = WSANO_ADDRESS;
  494.  
  495. { Windows Sockets errors redefined as regular Berkeley error constants.
  496.   These are commented out in Windows NT to avoid conflicts with errno.h.
  497.   Use the WSA constants instead. }
  498.  
  499.   EWOULDBLOCK        =  WSAEWOULDBLOCK;
  500.   EINPROGRESS        =  WSAEINPROGRESS;
  501.   EALREADY           =  WSAEALREADY;
  502.   ENOTSOCK           =  WSAENOTSOCK;
  503.   EDESTADDRREQ       =  WSAEDESTADDRREQ;
  504.   EMSGSIZE           =  WSAEMSGSIZE;
  505.   EPROTOTYPE         =  WSAEPROTOTYPE;
  506.   ENOPROTOOPT        =  WSAENOPROTOOPT;
  507.   EPROTONOSUPPORT    =  WSAEPROTONOSUPPORT;
  508.   ESOCKTNOSUPPORT    =  WSAESOCKTNOSUPPORT;
  509.   EOPNOTSUPP         =  WSAEOPNOTSUPP;
  510.   EPFNOSUPPORT       =  WSAEPFNOSUPPORT;
  511.   EAFNOSUPPORT       =  WSAEAFNOSUPPORT;
  512.   EADDRINUSE         =  WSAEADDRINUSE;
  513.   EADDRNOTAVAIL      =  WSAEADDRNOTAVAIL;
  514.   ENETDOWN           =  WSAENETDOWN;
  515.   ENETUNREACH        =  WSAENETUNREACH;
  516.   ENETRESET          =  WSAENETRESET;
  517.   ECONNABORTED       =  WSAECONNABORTED;
  518.   ECONNRESET         =  WSAECONNRESET;
  519.   ENOBUFS            =  WSAENOBUFS;
  520.   EISCONN            =  WSAEISCONN;
  521.   ENOTCONN           =  WSAENOTCONN;
  522.   ESHUTDOWN          =  WSAESHUTDOWN;
  523.   ETOOMANYREFS       =  WSAETOOMANYREFS;
  524.   ETIMEDOUT          =  WSAETIMEDOUT;
  525.   ECONNREFUSED       =  WSAECONNREFUSED;
  526.   ELOOP              =  WSAELOOP;
  527.   ENAMETOOLONG       =  WSAENAMETOOLONG;
  528.   EHOSTDOWN          =  WSAEHOSTDOWN;
  529.   EHOSTUNREACH       =  WSAEHOSTUNREACH;
  530.   ENOTEMPTY          =  WSAENOTEMPTY;
  531.   EPROCLIM           =  WSAEPROCLIM;
  532.   EUSERS             =  WSAEUSERS;
  533.   EDQUOT             =  WSAEDQUOT;
  534.   ESTALE             =  WSAESTALE;
  535.   EREMOTE            =  WSAEREMOTE;
  536.  
  537.  
  538. { Socket function prototypes }
  539.  
  540. function accept(s: TSocket; var addr: TSockAddr; var addrlen: Integer): TSocket; stdcall;
  541. function bind(s: TSocket; var addr: TSockAddr; namelen: Integer): Integer; stdcall;
  542. function closesocket(s: TSocket): Integer; stdcall;
  543. function connect(s: TSocket; var name: TSockAddr; namelen: Integer): Integer; stdcall;
  544. function ioctlsocket(s: TSocket; cmd: Longint; var arg: u_long): Integer; stdcall;
  545. function getpeername(s: TSocket; var name: TSockAddr; var namelen: Integer): Integer; stdcall;
  546. function getsockname(s: TSocket; var name: TSockAddr; var namelen: Integer): Integer; stdcall;
  547. function getsockopt(s: TSocket; level, optname: Integer; optval: PChar; var optlen: Integer): Integer; stdcall;
  548. function htonl(hostlong: u_long): u_long; stdcall;
  549. function htons(hostshort: u_short): u_short; stdcall;
  550. function inet_addr(cp: PChar): u_long; stdcall; {PInAddr;}  { TInAddr }
  551. function inet_ntoa(inaddr: TInAddr): PChar; stdcall;
  552. function listen(s: TSocket; backlog: Integer): Integer; stdcall;
  553. function ntohl(netlong: u_long): u_long; stdcall;
  554. function ntohs(netshort: u_short): u_short; stdcall;
  555. function recv(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;
  556. function recvfrom(s: TSocket; var Buf; len, flags: Integer;
  557.   var from: TSockAddr; var fromlen: Integer): Integer; stdcall;
  558. function select(nfds: Integer; readfds, writefds, exceptfds: PFDSet;
  559.   timeout: PTimeVal): Longint; stdcall;
  560. function send(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;
  561. function sendto(s: TSocket; var Buf; len, flags: Integer; var addrto: TSockAddr;
  562.   tolen: Integer): Integer; stdcall;
  563. function setsockopt(s: TSocket; level, optname: Integer; optval: PChar;
  564.   optlen: Integer): Integer; stdcall;
  565. function shutdown(s: TSocket; how: Integer): Integer; stdcall;
  566. function socket(af, struct, protocol: Integer): TSocket; stdcall;
  567. function gethostbyaddr(addr: Pointer; len, struct: Integer): PHostEnt; stdcall;
  568. function gethostbyname(name: PChar): PHostEnt; stdcall;
  569. function gethostname(name: PChar; len: Integer): Integer; stdcall;
  570. function getservbyport(port: Integer; proto: PChar): PServEnt; stdcall;
  571. function getservbyname(name, proto: PChar): PServEnt; stdcall;
  572. function getprotobynumber(proto: Integer): PProtoEnt; stdcall;
  573. function getprotobyname(name: PChar): PProtoEnt; stdcall;
  574. function WSAStartup(wVersionRequired: word; var WSData: TWSAData): Integer; stdcall;
  575. function WSACleanup: Integer; stdcall;
  576. procedure WSASetLastError(iError: Integer); stdcall;
  577. function WSAGetLastError: Integer; stdcall;
  578. function WSAIsBlocking: BOOL; stdcall;
  579. function WSAUnhookBlockingHook: Integer; stdcall;
  580. function WSASetBlockingHook(lpBlockFunc: TFarProc): TFarProc; stdcall;
  581. function WSACancelBlockingCall: Integer; stdcall;
  582. function WSAAsyncGetServByName(HWindow: HWND; wMsg: u_int; 
  583.   name, proto, buf: PChar; buflen: Integer): THandle; stdcall;
  584. function WSAAsyncGetServByPort( HWindow: HWND; wMsg, port: u_int; 
  585.   proto, buf: PChar; buflen: Integer): THandle; stdcall;
  586. function WSAAsyncGetProtoByName(HWindow: HWND; wMsg: u_int;
  587.   name, buf: PChar; buflen: Integer): THandle; stdcall;
  588. function WSAAsyncGetProtoByNumber(HWindow: HWND; wMsg: u_int; number: Integer;
  589.   buf: PChar; buflen: Integer): THandle; stdcall;
  590. function WSAAsyncGetHostByName(HWindow: HWND; wMsg: u_int; 
  591.   name, buf: PChar; buflen: Integer): THandle; stdcall;
  592. function WSAAsyncGetHostByAddr(HWindow: HWND; wMsg: u_int; addr: PChar; 
  593.   len, struct: Integer; buf: PChar; buflen: Integer): THandle; stdcall;
  594. function WSACancelAsyncRequest(hAsyncTaskHandle: THandle): Integer; stdcall;
  595. function WSAAsyncSelect(s: TSocket; HWindow: HWND; wMsg: u_int; lEvent: Longint): Integer; stdcall;
  596. function WSARecvEx(s: TSocket; var buf; len: Integer; var flags: Integer): Integer; stdcall;
  597.  
  598. function TransmitFile(hSocket: TSocket; hFile: THandle; nNumberOfBytesToWrite: DWORD;
  599.   nNumberOfBytesPerSend: DWORD; lpOverlapped: POverlapped;
  600.   lpTransmitBuffers: PTransmitFileBuffers; dwReserved: DWORD): BOOL; stdcall;
  601.  
  602. function WSAMakeSyncReply(Buflen, Error: Word): Longint;
  603. function WSAMakeSelectReply(Event, Error: Word): Longint;
  604. function WSAGetAsyncBuflen(Param: Longint): Word;
  605. function WSAGetAsyncError(Param: Longint): Word;
  606. function WSAGetSelectEvent(Param: Longint): Word;
  607. function WSAGetSelectError(Param: Longint): Word;
  608.  
  609. implementation
  610.  
  611. const
  612.   winsocket = 'wsock32.dll';
  613.  
  614. function WSAMakeSyncReply;
  615. begin
  616.   WSAMakeSyncReply:= MakeLong(Buflen, Error);
  617. end;
  618.  
  619. function WSAMakeSelectReply;
  620. begin
  621.   WSAMakeSelectReply:= MakeLong(Event, Error);
  622. end;
  623.  
  624. function WSAGetAsyncBuflen;
  625. begin
  626.   WSAGetAsyncBuflen:= LOWORD(Param);
  627. end;
  628.  
  629. function WSAGetAsyncError;
  630. begin
  631.   WSAGetAsyncError:= HIWORD(Param);
  632. end;
  633.  
  634. function WSAGetSelectEvent;
  635. begin
  636.   WSAGetSelectEvent:= LOWORD(Param);
  637. end;
  638.  
  639. function WSAGetSelectError;
  640. begin
  641.   WSAGetSelectError:= HIWORD(Param);
  642. end;
  643.  
  644. function accept;            external    winsocket name 'accept';
  645. function bind;              external    winsocket name 'bind';
  646. function closesocket;       external    winsocket name 'closesocket';
  647. function connect;           external    winsocket name 'connect';
  648. function getpeername;       external    winsocket name 'getpeername';
  649. function getsockname;       external    winsocket name 'getsockname';
  650. function getsockopt;        external    winsocket name 'getsockopt';
  651. function htonl;             external    winsocket name 'htonl';
  652. function htons;             external    winsocket name 'htons';
  653. function inet_addr;         external    winsocket name 'inet_addr';
  654. function inet_ntoa;         external    winsocket name 'inet_ntoa';
  655. function ioctlsocket;       external    winsocket name 'ioctlsocket';
  656. function listen;            external    winsocket name 'listen';
  657. function ntohl;             external    winsocket name 'ntohl';
  658. function ntohs;             external    winsocket name 'ntohs';
  659. function recv;              external    winsocket name 'recv';
  660. function recvfrom;          external    winsocket name 'recvfrom';
  661. function select;            external    winsocket name 'select';
  662. function send;              external    winsocket name 'send';
  663. function sendto;            external    winsocket name 'sendto';
  664. function setsockopt;        external    winsocket name 'setsockopt';
  665. function shutdown;          external    winsocket name 'shutdown';
  666. function socket;            external    winsocket name 'socket';
  667.  
  668. function gethostbyaddr;     external    winsocket name 'gethostbyaddr';
  669. function gethostbyname;     external    winsocket name 'gethostbyname';
  670. function getprotobyname;    external    winsocket name 'getprotobyname';
  671. function getprotobynumber;  external    winsocket name 'getprotobynumber';
  672. function getservbyname;     external    winsocket name 'getservbyname';
  673. function getservbyport;     external    winsocket name 'getservbyport';
  674. function gethostname;       external    winsocket name 'gethostname';
  675.  
  676. function WSAAsyncSelect;    external    winsocket name 'WSAAsyncSelect';
  677. function WSARecvEx;         external    winsocket name 'WSARecvEx';
  678. function WSAAsyncGetHostByAddr; external winsocket name 'WSAAsyncGetHostByAddr';
  679. function WSAAsyncGetHostByName; external winsocket name 'WSAAsyncGetHostByName';
  680. function WSAAsyncGetProtoByNumber; external winsocket name 'WSAAsyncGetProtoByNumber';
  681. function WSAAsyncGetprotoByName; external winsocket name 'WSAAsyncGetprotoByName';
  682. function WSAAsyncGetServByPort; external winsocket name 'WSAAsyncGetServByPort';
  683. function WSAAsyncGetServByName; external winsocket name 'WSAAsyncGetServByName';
  684. function WSACancelAsyncRequest; external winsocket name 'WSACancelAsyncRequest';
  685. function WSASetBlockingHook; external    winsocket name 'WSASetBlockingHook';
  686. function WSAUnhookBlockingHook; external winsocket name 'WSAUnhookBlockingHook';
  687. function WSAGetLastError;    external    winsocket name 'WSAGetLastError';
  688. procedure WSASetLastError;   external    winsocket name 'WSASetLastError';
  689. function WSACancelBlockingCall; external winsocket name 'WSACancelBlockingCall';
  690. function WSAIsBlocking;     external     winsocket name 'WSAIsBlocking';
  691. function WSAStartup;        external     winsocket name 'WSAStartup';
  692. function WSACleanup;        external     winsocket name 'WSACleanup';
  693.  
  694. function TransmitFile;      external     winsocket name 'TransmitFile';
  695.  
  696. end.
  697.