home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 March / Chip_1999-03_cd.bin / zkuste / delphi / INFO / DI9806JP.ZIP / Winsock2.pas < prev    next >
Pascal/Delphi Source File  |  1998-01-26  |  59KB  |  1,715 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Windows Sockets API v. 2.20 Header File         }
  4. {                            }
  5. {        Prerelease 16.09.96            }
  6. {                            }
  7. {       Base:      WinSock2.h from Winsock SDK 1.6 BETA  }
  8. {                 Delphi 2 RTL Windows32 API Interface  }
  9. {                            }
  10. {       (c) 1996 by Artur Grajek 'AHS'                  }
  11. {    email: c51725ag@juggernaut.eti.pg.gda.pl    }
  12. {*******************************************************}
  13. {                                                       }
  14. {                                                       }
  15. { List of Modifications :                               }
  16. { Removed WS2's type definition of TGUID, and now use   }
  17. { the TGUID type as defined in the D3's COMOBJ unit     }
  18. { Modified by JCP 271197                                }
  19. {                                                       }
  20. {                                                       }
  21. {                                                       }
  22. {*******************************************************}
  23.  
  24. unit WinSock2;
  25.  
  26. interface
  27.  
  28. uses Windows, comobj;// Added COMOBJ for TGUID type reference JCP 271197
  29.  
  30. type
  31.   u_char = Char;
  32.   u_short = Word;
  33.   u_int = Integer;
  34.   u_long = Longint;
  35.   pu_long = ^u_long;
  36.   pu_short = ^u_short;
  37.  
  38. { The new type to be used in all
  39.   instances which refer to sockets. }
  40.   TSocket = u_int;
  41.  
  42. const
  43.   FD_SETSIZE     =   64;
  44.  
  45. type
  46.   PFDSet = ^TFDSet;
  47.   TFDSet = packed record
  48.     fd_count: u_int;
  49.     fd_array: array[0..FD_SETSIZE-1] of TSocket;
  50.   end;
  51.  
  52.   PTimeVal = ^TTimeVal;
  53.   TTimeVal = packed record
  54.     tv_sec: Longint;
  55.     tv_usec: Longint;
  56.   end;
  57.  
  58. const
  59.   IOCPARM_MASK = $7f;
  60.   IOC_VOID     = $20000000;
  61.   IOC_OUT      = $40000000;
  62.   IOC_IN       = $80000000;
  63.   IOC_INOUT    = (IOC_IN or IOC_OUT);
  64.  
  65.   FIONREAD     = IOC_OUT or { get # bytes to read }
  66.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  67.     (Longint(Byte('f')) shl 8) or 127;
  68.   FIONBIO      = IOC_IN or { set/clear non-blocking i/o }
  69.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  70.     (Longint(Byte('f')) shl 8) or 126;
  71.   FIOASYNC     = IOC_IN or { set/clear async i/o }
  72.     ((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
  73.     (Longint(Byte('f')) shl 8) or 125;
  74.  
  75.  
  76. const
  77.  
  78. { Protocols }
  79.  
  80.   IPPROTO_IP     =   0;        { Dummy                    }
  81.   IPPROTO_ICMP   =   1;        { Internet Control Message Protocol }
  82.   IPPROTO_IGMP   =   2;        { Internet Group Management Protocol}
  83.   IPPROTO_GGP    =   3;        { Gateway                           }
  84.   IPPROTO_TCP    =   6;        { TCP                       }
  85.   IPPROTO_PUP    =   12;    { PUP                    }
  86.   IPPROTO_UDP    =   17;    { User Datagram Protocol        }
  87.   IPPROTO_IDP    =   22;    { XNS IDP                }
  88.   IPPROTO_ND     =   77;    { UNOFFICIAL Net Disk Protocol    }
  89.  
  90.   IPPROTO_RAW    =   255;
  91.   IPPROTO_MAX    =   256;
  92.  
  93. { Port/socket numbers: network standard functions}
  94.  
  95.   IPPORT_ECHO    =   7;
  96.   IPPORT_DISCARD =   9;
  97.   IPPORT_SYSTAT  =   11;
  98.   IPPORT_DAYTIME =   13;
  99.   IPPORT_NETSTAT =   15;
  100.   IPPORT_FTP     =   21;
  101.   IPPORT_TELNET  =   23;
  102.   IPPORT_SMTP    =   25;
  103.   IPPORT_TIMESERVER  =  37;
  104.   IPPORT_NAMESERVER  =  42;
  105.   IPPORT_WHOIS       =  43;
  106.   IPPORT_MTP         =  57;
  107.  
  108. { Port/socket numbers: host specific functions }
  109.  
  110.   IPPORT_TFTP        =  69;
  111.   IPPORT_RJE         =  77;
  112.   IPPORT_FINGER      =  79;
  113.   IPPORT_TTYLINK     =  87;
  114.   IPPORT_SUPDUP      =  95;
  115.  
  116. { UNIX TCP sockets }
  117.   
  118.   IPPORT_EXECSERVER  =  512;
  119.   IPPORT_LOGINSERVER =  513;
  120.   IPPORT_CMDSERVER   =  514;
  121.   IPPORT_EFSSERVER   =  520;
  122.   
  123. { UNIX UDP sockets }
  124.  
  125.   IPPORT_BIFFUDP     =  512;
  126.   IPPORT_WHOSERVER   =  513;
  127.   IPPORT_ROUTESERVER =  520;
  128.   
  129. { Ports < IPPORT_RESERVED are reserved for
  130.   privileged processes (e.g. root). }
  131.  
  132.   IPPORT_RESERVED    =  1024;
  133.   
  134. { Link numbers }
  135.  
  136.   IMPLINK_IP         =  155;
  137.   IMPLINK_LOWEXPER   =  156;
  138.   IMPLINK_HIGHEXPER  =  158;
  139.  
  140. type
  141.   SunB = packed record
  142.     s_b1, s_b2, s_b3, s_b4: u_char;
  143.   end;
  144.  
  145.   SunW = packed record
  146.     s_w1, s_w2: u_short;
  147.   end;
  148.  
  149.   PInAddr = ^TInAddr;
  150.   TInAddr = packed record
  151.     case integer of
  152.       0: (S_un_b: SunB);
  153.       1: (S_un_w: SunW);
  154.       2: (S_addr: u_long);
  155.   end;
  156.  
  157.   PSockAddrIn = ^TSockAddrIn;
  158.   TSockAddrIn = packed record
  159.     case Integer of
  160.       0: (sin_family: u_short;
  161.           sin_port: u_short;
  162.           sin_addr: TInAddr;
  163.           sin_zero: array[0..7] of Char);
  164.       1: (sa_family: u_short;
  165.           sa_data: array[0..13] of Char)
  166.   end;
  167. type
  168.   PHostEnt = ^THostEnt;
  169.   THostEnt = packed record
  170.     h_name: PChar;
  171.     h_aliases: ^PChar;
  172.     h_addrtype: Smallint;
  173.     h_length: Smallint;
  174.     case integer of
  175.      0: (h_addr_list: ^PChar);
  176.      1: (h_addr: ^PInAddr);
  177.   end;
  178.  
  179.   PNetEnt = ^TNetEnt;
  180.   TNetEnt = packed record
  181.     n_name: PChar;
  182.     n_aliases: ^PChar;
  183.     n_addrtype: Smallint;
  184.     n_net: u_long;
  185.   end;
  186.  
  187.   PServEnt = ^TServEnt;
  188.   TServEnt = packed record
  189.     s_name: PChar;
  190.     s_aliases: ^PChar;
  191.     s_port: Smallint;
  192.     s_proto: PChar;
  193.   end;
  194.  
  195.   PProtoEnt = ^TProtoEnt;
  196.   TProtoEnt = packed record
  197.     p_name: PChar;
  198.     p_aliases: ^Pchar;
  199.     p_proto: Smallint;
  200.   end;
  201.  
  202. const
  203.   INADDR_ANY       = $00000000;
  204.   INADDR_LOOPBACK  = $7F000001;
  205.   INADDR_BROADCAST = $FFFFFFFF;
  206.   INADDR_NONE      = $FFFFFFFF;
  207.  
  208.   ADDR_ANY         = INADDR_ANY;
  209.  
  210. const
  211.   WSADESCRIPTION_LEN     =   256;
  212.   WSASYS_STATUS_LEN      =   128;
  213.  
  214. type
  215.   PWSAData = ^TWSAData;
  216.   TWSAData = packed record
  217.     wVersion: Word;
  218.     wHighVersion: Word;
  219.     szDescription: array[0..WSADESCRIPTION_LEN] of Char;
  220.     szSystemStatus: array[0..WSASYS_STATUS_LEN] of Char;
  221.     iMaxSockets: Word;
  222.     iMaxUdpDg: Word;
  223.     lpVendorInfo: PChar;
  224.   end;
  225.  
  226.   PTransmitFileBuffers = ^TTransmitFileBuffers;
  227.   TTransmitFileBuffers = packed record
  228.       Head: Pointer;
  229.       HeadLength: DWORD;
  230.       Tail: Pointer;
  231.       TailLength: DWORD;
  232.   end;
  233.  
  234. const
  235.  
  236. { Options for use with [gs]etsockopt at the IP level. }
  237.  (*
  238.   IP_OPTIONS          = 1;
  239.   IP_MULTICAST_IF     = 2;           { set/get IP multicast interface   }
  240.   IP_MULTICAST_TTL    = 3;           { set/get IP multicast timetolive  }
  241.   IP_MULTICAST_LOOP   = 4;           { set/get IP multicast loopback    }
  242.   IP_ADD_MEMBERSHIP   = 5;           { add  an IP group membership      }
  243.   IP_DROP_MEMBERSHIP  = 6;           { drop an IP group membership      }
  244.  
  245.   IP_DEFAULT_MULTICAST_TTL   = 1;    { normally limit m'casts to 1 hop  }
  246.   IP_DEFAULT_MULTICAST_LOOP  = 1;    { normally hear sends if a member  }
  247.    { per socket; must fit in one mbuf }
  248. *)
  249. //
  250.   IP_OPTIONS          = 1;  //* set/get IP options */
  251.   IP_HDRINCL          = 2;  //* header is included with data */
  252.   IP_TOS              = 3;  //* IP type of service and preced*/
  253.   IP_TTL              = 4;  //* IP time to live */
  254.   IP_MULTICAST_IF     = 9;  //* set/get IP multicast i/f  */
  255.   IP_MULTICAST_TTL    = 10; //* set/get IP multicast ttl */
  256.   IP_MULTICAST_LOOP   = 11; //*set/get IP multicast loopback */
  257.   IP_ADD_MEMBERSHIP   = 12; //* add an IP group membership */
  258.   IP_DROP_MEMBERSHIP  = 13; //* drop an IP group membership */
  259.   IP_DONTFRAGMENT     = 14; //* don't fragment IP datagrams */
  260.  
  261. // Option to use with [gs]etsockopt at the IPPROTO_UDP level */
  262.  
  263.    UDP_NOCHECKSUM     = 1;
  264.  
  265. //* Option to use with [gs]etsockopt at the IPPROTO_TCP level */
  266.  
  267.     TCP_EXPEDITED_1122 = $0002;
  268.  
  269.  
  270.  
  271. { This is used instead of -1, since the
  272.   TSocket type is unsigned.}
  273.  
  274.   INVALID_SOCKET        = TSocket(NOT(0));
  275.   SOCKET_ERROR        = -1;
  276.  
  277. { The  following  may  be used in place of the address family, socket type, or
  278.   protocol  in  a  call  to WSASocket to indicate that the corresponding value
  279.   should  be taken from the supplied WSAPROTOCOL_INFO structure instead of the
  280.   parameter itself.
  281.  }
  282.  
  283.   FROM_PROTOCOL_INFO    = -1;
  284.  
  285. { Types }
  286.  
  287.   SOCK_STREAM     = 1;               { stream socket }
  288.   SOCK_DGRAM      = 2;               { datagram socket }
  289.   SOCK_RAW        = 3;               { raw-protocol interface }
  290.   SOCK_RDM        = 4;               { reliably-delivered message }
  291.   SOCK_SEQPACKET  = 5;               { sequenced packet stream }
  292.  
  293. { Option flags per-socket. }
  294.  
  295.   SO_DEBUG        = $0001;          { turn on debugging info recording }
  296.   SO_ACCEPTCONN   = $0002;          { socket has had listen() }
  297.   SO_REUSEADDR    = $0004;          { allow local address reuse }
  298.   SO_KEEPALIVE    = $0008;          { keep connections alive }
  299.   SO_DONTROUTE    = $0010;          { just use interface addresses }
  300.   SO_BROADCAST    = $0020;          { permit sending of broadcast msgs }
  301.   SO_USELOOPBACK  = $0040;          { bypass hardware when possible }
  302.   SO_LINGER       = $0080;          { linger on close if data present }
  303.   SO_OOBINLINE    = $0100;          { leave received OOB data in line }
  304.  
  305.   SO_DONTLINGER  =   $ff7f;
  306.  
  307. { Additional options. }
  308.  
  309.   SO_SNDBUF       = $1001;          { send buffer size }
  310.   SO_RCVBUF       = $1002;          { receive buffer size }
  311.   SO_SNDLOWAT     = $1003;          { send low-water mark }
  312.   SO_RCVLOWAT     = $1004;          { receive low-water mark }
  313.   SO_SNDTIMEO     = $1005;          { send timeout }
  314.   SO_RCVTIMEO     = $1006;          { receive timeout }
  315.   SO_ERROR        = $1007;          { get error status and clear }
  316.   SO_TYPE         = $1008;          { get socket type }
  317.  
  318. { Options for connect and disconnect data and options.  Used only by
  319.   non-TCP/IP transports such as DECNet, OSI TP4, etc. }
  320.  
  321.   SO_CONNDATA     = $7000;
  322.   SO_CONNOPT      = $7001;
  323.   SO_DISCDATA     = $7002;
  324.   SO_DISCOPT      = $7003;
  325.   SO_CONNDATALEN  = $7004;
  326.   SO_CONNOPTLEN   = $7005;
  327.   SO_DISCDATALEN  = $7006;
  328.   SO_DISCOPTLEN   = $7007;
  329.  
  330. { WinSock 2 extension -- new options }
  331.  
  332.   SO_GROUP_ID       = $2001; { ID of a socket group}
  333.   SO_GROUP_PRIORITY = $2002; { the relative priority within a group}
  334.   SO_MAX_MSG_SIZE   = $2003; { maximum message size }
  335.   SO_PROTOCOL_INFOA = $2004; { WSAPROTOCOL_INFOA structure }
  336.   SO_PROTOCOL_INFOW = $2005; { WSAPROTOCOL_INFOW structure }
  337.  
  338. {$IFDEF UNICODE }
  339.   SO_PROTOCOL_INFO  = SO_PROTOCOL_INFOW;
  340. {$ELSE }
  341.   SO_PROTOCOL_INFO  = SO_PROTOCOL_INFOA;
  342. {$ENDIF UNICODE }
  343.   PVD_CONFIG        = $3001; {configuration info for service provider }
  344.  
  345. { Option for opening sockets for synchronous access. }
  346.  
  347.   SO_OPENTYPE     = $7008;
  348.  
  349.   SO_SYNCHRONOUS_ALERT    = $10;
  350.   SO_SYNCHRONOUS_NONALERT = $20;
  351.  
  352. { Other NT-specific options. }
  353.  
  354.   SO_MAXDG        = $7009;
  355.   SO_MAXPATHDG    = $700A;
  356.  
  357. { TCP options. }
  358.  
  359.   TCP_NODELAY     = $0001;
  360.   TCP_BSDURGENT   = $7000;
  361.  
  362. { Address families. }
  363.  
  364.   AF_UNSPEC       = 0;               { unspecified }
  365.   AF_UNIX         = 1;               { local to host (pipes, portals) }
  366.   AF_INET         = 2;               { internetwork: UDP, TCP, etc. }
  367.   AF_IMPLINK      = 3;               { arpanet imp addresses }
  368.   AF_PUP          = 4;               { pup protocols: e.g. BSP }
  369.   AF_CHAOS        = 5;               { mit CHAOS protocols }
  370.   AF_IPX          = 6;               { IPX and SPX }
  371.   AF_NS           = 6;               { XEROX NS protocols }
  372.   AF_ISO          = 7;               { ISO protocols }
  373.   AF_OSI          = AF_ISO;          { OSI is ISO }
  374.   AF_ECMA         = 8;               { european computer manufacturers }
  375.   AF_DATAKIT      = 9;               { datakit protocols }
  376.   AF_CCITT        = 10;              { CCITT protocols, X.25 etc }
  377.   AF_SNA          = 11;              { IBM SNA }
  378.   AF_DECnet       = 12;              { DECnet }
  379.   AF_DLI          = 13;              { Direct data link interface }
  380.   AF_LAT          = 14;              { LAT }
  381.   AF_HYLINK       = 15;              { NSC Hyperchannel }
  382.   AF_APPLETALK    = 16;              { AppleTalk }
  383.   AF_NETBIOS      = 17;              { NetBios-style addresses }
  384.   AF_VOICEVIEW    = 18;              { VoiceView }
  385.   AF_FIREFOX      = 19;              { FireFox }
  386.   AF_UNKNOWN1     = 20;              { Somebody is using this! }
  387.   AF_BAN          = 21;              { Banyan }
  388.   AF_ATM          = 22;              { Native ATM Services }
  389.   AF_INET6        = 23;              { Internetwork Version 6 }
  390.  
  391.   AF_MAX          = 24;
  392.  
  393. type
  394.   { Structure used by kernel to store most addresses. }
  395.  
  396.   PSockAddr = ^TSockAddr;
  397.   TSockAddr = TSockAddrIn;
  398.  
  399.   { Structure used by kernel to pass protocol information in raw sockets. }
  400.   PSockProto = ^TSockProto;
  401.   TSockProto = packed record
  402.     sp_family: u_short;
  403.     sp_protocol: u_short;
  404.   end;
  405.  
  406. const
  407. { Protocol families, same as address families for now. }
  408.  
  409.   PF_UNSPEC       = AF_UNSPEC;
  410.   PF_UNIX         = AF_UNIX;
  411.   PF_INET         = AF_INET;
  412.   PF_IMPLINK      = AF_IMPLINK;
  413.   PF_PUP          = AF_PUP;
  414.   PF_CHAOS        = AF_CHAOS;
  415.   PF_NS           = AF_NS;
  416.   PF_IPX          = AF_IPX;
  417.   PF_ISO          = AF_ISO;
  418.   PF_OSI          = AF_OSI;
  419.   PF_ECMA         = AF_ECMA;
  420.   PF_DATAKIT      = AF_DATAKIT;
  421.   PF_CCITT        = AF_CCITT;
  422.   PF_SNA          = AF_SNA;
  423.   PF_DECnet       = AF_DECnet;
  424.   PF_DLI          = AF_DLI;
  425.   PF_LAT          = AF_LAT;
  426.   PF_HYLINK       = AF_HYLINK;
  427.   PF_APPLETALK    = AF_APPLETALK;
  428.   PF_VOICEVIEW    = AF_VOICEVIEW;
  429.   PF_FIREFOX      = AF_FIREFOX;
  430.   PF_UNKNOWN1     = AF_UNKNOWN1;
  431.   PF_BAN          = AF_BAN;
  432.   PF_ATM          = AF_ATM;
  433.   PF_INET6        = AF_INET6;
  434.  
  435.   PF_MAX          = AF_MAX;
  436.  
  437. type
  438. { Structure used for manipulating linger option. }
  439.   PLinger = ^TLinger;
  440.   TLinger = packed record
  441.     l_onoff: u_short;
  442.     l_linger: u_short;
  443.   end;
  444.  
  445. const
  446. { Level number for (get/set)sockopt() to apply to socket itself. }
  447.  
  448.   SOL_SOCKET      = $ffff;          {options for socket level }
  449.  
  450. { Maximum queue length specifiable by listen. }
  451.  
  452.   SOMAXCONN       = $7fffffff;      { AHS - by│o 5 !?????? }
  453.  
  454.   MSG_OOB         = $1;             {process out-of-band data }
  455.   MSG_PEEK        = $2;             {peek at incoming message }
  456.   MSG_DONTROUTE   = $4;             {send without using routing tables }
  457.  
  458.   MSG_MAXIOVLEN   = 16;
  459.  
  460.   MSG_PARTIAL     = $8000;          {partial send or recv for message xport }
  461.  
  462. { WinSock 2 extension -- new flags for WSASend(), WSASendTo(), WSARecv() and
  463.   WSARecvFrom() }
  464.  
  465.   MSG_INTERRUPT   = $10;            {send/recv in the interrupt context}
  466.  
  467. { Define constant based on rfc883, used by gethostbyxxxx() calls. }
  468.  
  469.   MAXGETHOSTSTRUCT        = 1024;
  470.  
  471. { Define flags to be used with the WSAAsyncSelect() call. }
  472.  
  473.   FD_READ         = $01;
  474.   FD_WRITE        = $02;
  475.   FD_OOB          = $04;
  476.   FD_ACCEPT       = $08;
  477.   FD_CONNECT      = $10;
  478.   FD_CLOSE        = $20;
  479.   FD_QOS          = $40;
  480.   FD_GROUP_QOS    = $80;
  481.   FD_MAX_EVENTS    = 8;
  482.   FD_ALL_EVENTS    = $100; { AHS - trudno powiedzieµ, ile powinno byµ }
  483.  
  484. { All Windows Sockets error constants are biased by WSABASEERR from the "normal" }
  485.  
  486.   WSABASEERR              = 10000;
  487.  
  488. { Windows Sockets definitions of regular Microsoft C error constants }
  489.  
  490.   WSAEINTR                = (WSABASEERR+4);
  491.   WSAEBADF                = (WSABASEERR+9);
  492.   WSAEACCES               = (WSABASEERR+13);
  493.   WSAEFAULT               = (WSABASEERR+14);
  494.   WSAEINVAL               = (WSABASEERR+22);
  495.   WSAEMFILE               = (WSABASEERR+24);
  496.  
  497. { Windows Sockets definitions of regular Berkeley error constants }
  498.  
  499.   WSAEWOULDBLOCK          = (WSABASEERR+35);
  500.   WSAEINPROGRESS          = (WSABASEERR+36);
  501.   WSAEALREADY             = (WSABASEERR+37);
  502.   WSAENOTSOCK             = (WSABASEERR+38);
  503.   WSAEDESTADDRREQ         = (WSABASEERR+39);
  504.   WSAEMSGSIZE             = (WSABASEERR+40);
  505.   WSAEPROTOTYPE           = (WSABASEERR+41);
  506.   WSAENOPROTOOPT          = (WSABASEERR+42);
  507.   WSAEPROTONOSUPPORT      = (WSABASEERR+43);
  508.   WSAESOCKTNOSUPPORT      = (WSABASEERR+44);
  509.   WSAEOPNOTSUPP           = (WSABASEERR+45);
  510.   WSAEPFNOSUPPORT         = (WSABASEERR+46);
  511.   WSAEAFNOSUPPORT         = (WSABASEERR+47);
  512.   WSAEADDRINUSE           = (WSABASEERR+48);
  513.   WSAEADDRNOTAVAIL        = (WSABASEERR+49);
  514.   WSAENETDOWN             = (WSABASEERR+50);
  515.   WSAENETUNREACH          = (WSABASEERR+51);
  516.   WSAENETRESET            = (WSABASEERR+52);
  517.   WSAECONNABORTED         = (WSABASEERR+53);
  518.   WSAECONNRESET           = (WSABASEERR+54);
  519.   WSAENOBUFS              = (WSABASEERR+55);
  520.   WSAEISCONN              = (WSABASEERR+56);
  521.   WSAENOTCONN             = (WSABASEERR+57);
  522.   WSAESHUTDOWN            = (WSABASEERR+58);
  523.   WSAETOOMANYREFS         = (WSABASEERR+59);
  524.   WSAETIMEDOUT            = (WSABASEERR+60);
  525.   WSAECONNREFUSED         = (WSABASEERR+61);
  526.   WSAELOOP                = (WSABASEERR+62);
  527.   WSAENAMETOOLONG         = (WSABASEERR+63);
  528.   WSAEHOSTDOWN            = (WSABASEERR+64);
  529.   WSAEHOSTUNREACH         = (WSABASEERR+65);
  530.   WSAENOTEMPTY            = (WSABASEERR+66);
  531.   WSAEPROCLIM             = (WSABASEERR+67);
  532.   WSAEUSERS               = (WSABASEERR+68);
  533.   WSAEDQUOT               = (WSABASEERR+69);
  534.   WSAESTALE               = (WSABASEERR+70);
  535.   WSAEREMOTE              = (WSABASEERR+71);
  536.  
  537. { Extended Windows Sockets error constant definitions }
  538.  
  539.   WSASYSNOTREADY          = (WSABASEERR+91);
  540.   WSAVERNOTSUPPORTED      = (WSABASEERR+92);
  541.   WSANOTINITIALISED       = (WSABASEERR+93);
  542.   WSAEDISCON              = (WSABASEERR+101);
  543.   WSAENOMORE              = (WSABASEERR+102);
  544.   WSAECANCELLED           = (WSABASEERR+103);
  545.   WSAEEINVALIDPROCTABLE   = (WSABASEERR+104);
  546.   WSAEINVALIDPROVIDER     = (WSABASEERR+105);
  547.   WSAEPROVIDERFAILEDINIT  = (WSABASEERR+106);
  548.   WSASYSCALLFAILURE       = (WSABASEERR+107);
  549.   WSASERVICE_NOT_FOUND    = (WSABASEERR+108);
  550.   WSATYPE_NOT_FOUND       = (WSABASEERR+109);
  551.   WSA_E_NO_MORE           = (WSABASEERR+110);
  552.   WSA_E_CANCELLED         = (WSABASEERR+111);
  553.   WSAEREFUSED             = (WSABASEERR+112);
  554.  
  555. { Error return codes from gethostbyname() and gethostbyaddr()
  556.   (when using the resolver). Note that these errors are
  557.   retrieved via WSAGetLastError() and must therefore follow
  558.   the rules for avoiding clashes with error numbers from
  559.   specific implementations or language run-time systems.
  560.   For this reason the codes are based at WSABASEERR+1001.
  561.   Note also that [WSA]NO_ADDRESS is defined only for
  562.   compatibility purposes. }
  563.  
  564. { Authoritative Answer: Host not found }
  565.  
  566.   WSAHOST_NOT_FOUND       = (WSABASEERR+1001);
  567.   HOST_NOT_FOUND          = WSAHOST_NOT_FOUND;
  568.  
  569. { Non-Authoritative: Host not found, or SERVERFAIL }
  570.  
  571.   WSATRY_AGAIN            = (WSABASEERR+1002);
  572.   TRY_AGAIN               = WSATRY_AGAIN;
  573.  
  574. { Non recoverable errors, FORMERR, REFUSED, NOTIMP }
  575.  
  576.   WSANO_RECOVERY          = (WSABASEERR+1003);
  577.   NO_RECOVERY             = WSANO_RECOVERY;
  578.  
  579. { Valid name, no data record of requested type }
  580.  
  581.   WSANO_DATA              = (WSABASEERR+1004);
  582.   NO_DATA                 = WSANO_DATA;
  583.  
  584. { no address, look for MX record }
  585.  
  586.   WSANO_ADDRESS           = WSANO_DATA;
  587.   NO_ADDRESS              = WSANO_ADDRESS;
  588.  
  589. { Windows Sockets errors redefined as regular Berkeley error constants.
  590.   These are commented out in Windows NT to avoid conflicts with errno.h.
  591.   Use the WSA constants instead. }
  592.  
  593.   EWOULDBLOCK        =  WSAEWOULDBLOCK;
  594.   EINPROGRESS        =  WSAEINPROGRESS;
  595.   EALREADY           =  WSAEALREADY;
  596.   ENOTSOCK           =  WSAENOTSOCK;
  597.   EDESTADDRREQ       =  WSAEDESTADDRREQ;
  598.   EMSGSIZE           =  WSAEMSGSIZE;
  599.   EPROTOTYPE         =  WSAEPROTOTYPE;
  600.   ENOPROTOOPT        =  WSAENOPROTOOPT;
  601.   EPROTONOSUPPORT    =  WSAEPROTONOSUPPORT;
  602.   ESOCKTNOSUPPORT    =  WSAESOCKTNOSUPPORT;
  603.   EOPNOTSUPP         =  WSAEOPNOTSUPP;
  604.   EPFNOSUPPORT       =  WSAEPFNOSUPPORT;
  605.   EAFNOSUPPORT       =  WSAEAFNOSUPPORT;
  606.   EADDRINUSE         =  WSAEADDRINUSE;
  607.   EADDRNOTAVAIL      =  WSAEADDRNOTAVAIL;
  608.   ENETDOWN           =  WSAENETDOWN;
  609.   ENETUNREACH        =  WSAENETUNREACH;
  610.   ENETRESET          =  WSAENETRESET;
  611.   ECONNABORTED       =  WSAECONNABORTED;
  612.   ECONNRESET         =  WSAECONNRESET;
  613.   ENOBUFS            =  WSAENOBUFS;
  614.   EISCONN            =  WSAEISCONN;
  615.   ENOTCONN           =  WSAENOTCONN;
  616.   ESHUTDOWN          =  WSAESHUTDOWN;
  617.   ETOOMANYREFS       =  WSAETOOMANYREFS;
  618.   ETIMEDOUT          =  WSAETIMEDOUT;
  619.   ECONNREFUSED       =  WSAECONNREFUSED;
  620.   ELOOP              =  WSAELOOP;
  621.   ENAMETOOLONG       =  WSAENAMETOOLONG;
  622.   EHOSTDOWN          =  WSAEHOSTDOWN;
  623.   EHOSTUNREACH       =  WSAEHOSTUNREACH;
  624.   ENOTEMPTY          =  WSAENOTEMPTY;
  625.   EPROCLIM           =  WSAEPROCLIM;
  626.   EUSERS             =  WSAEUSERS;
  627.   EDQUOT             =  WSAEDQUOT;
  628.   ESTALE             =  WSAESTALE;
  629.   EREMOTE            =  WSAEREMOTE;
  630.  
  631. { AHS }
  632. { WinSock 2 extension -- new error codes and type definition }
  633.  
  634. type
  635.   WSAEVENT                = THANDLE;
  636.   LPHANDLE                = PHANDLE;
  637.   LPWSAEVENT              = LPHANDLE;
  638.   WSAOVERLAPPED           = TOVERLAPPED;
  639.   LPWSAOVERLAPPED         = POverlapped;
  640.  
  641. const
  642.  
  643.   WSA_IO_PENDING          = ERROR_IO_PENDING;
  644.   WSA_IO_INCOMPLETE       = ERROR_IO_INCOMPLETE;
  645.   WSA_INVALID_HANDLE      = ERROR_INVALID_HANDLE;
  646.   WSA_INVALID_PARAMETER   = ERROR_INVALID_PARAMETER;
  647.   WSA_NOT_ENOUGH_MEMORY   = ERROR_NOT_ENOUGH_MEMORY;
  648.   WSA_OPERATION_ABORTED   = ERROR_OPERATION_ABORTED;
  649.  
  650.   WSA_INVALID_EVENT       = WSAEVENT(NiL);
  651.   WSA_MAXIMUM_WAIT_EVENTS = MAXIMUM_WAIT_OBJECTS;
  652.   WSA_WAIT_FAILED         = DWORD($FFFFFFFF); { ahs }
  653.   WSA_WAIT_EVENT_0        = WAIT_OBJECT_0;
  654.   WSA_WAIT_IO_COMPLETION  = WAIT_IO_COMPLETION;
  655.   WSA_WAIT_TIMEOUT        = WAIT_TIMEOUT;
  656.   WSA_INFINITE            = INFINITE;
  657.  
  658.  
  659. { WinSock 2 extension -- WSABUF and QOS struct }
  660.  
  661. type
  662.  
  663. PWSABUF = ^TWSABUF;
  664. TWSABUF = packed record
  665.   len                : u_long;     { the length of the buffer }
  666.   buf                : PChar;     { the pointer to the buffer }
  667. end;
  668.  
  669. GUARANTEE = (
  670.     BestEffortService,
  671.     ControlledLoadService,
  672.     PredictiveService,
  673.     GuaranteedDelayService,
  674.     GuaranteedService
  675. );
  676.  
  677. PFlowspec = ^TFlowspec;
  678. TFlowspec = packed record
  679.   TokenRate             : LongInt;        { In Bytes/sec }
  680.   TokenBucketSize       : LongInt;        { In Bytes }
  681.   PeakBandwidth         : LongInt;        { In Bytes/sec }
  682.   Latency               : LongInt;        { In microseconds }
  683.   DelayVariation        : LongInt;        { In microseconds }
  684.   LevelOfGuarantee      : Guarantee;      { Guaranteed, Predictive }
  685.                                           { or Best Effort       }
  686.   CostOfCall            : LongInt;        { Reserved for future use, }
  687.                                           { must be set to 0 now   }
  688.   NetworkAvailability   : LongInt;        { read-only:         }
  689.                                           {   1 if accessible, }
  690.                                           {   0 if not         }
  691. end;
  692.  
  693. PQOS = ^TQualityOfService;
  694. TQualityOfService = packed record
  695.   SendingFlowspec       :TFlowspec;    { the flow spec for data sending }
  696.   ReceivingFlowspec     :TFlowspec;    { the flow spec for data receiving }
  697.   ProviderSpecific      :TWSABuf;      { additional provider specific stuff }
  698. end;
  699.  
  700. const
  701.  
  702. { WinSock 2 extension -- manifest constants for return values of the
  703.   condition function}
  704.  
  705.   CF_ACCEPT       = $0000;
  706.   CF_REJECT       = $0001;
  707.   CF_DEFER        = $0002;
  708.  
  709. {WinSock 2 extension -- manifest constants for shutdown() }
  710.  
  711.   SD_RECEIVE      = $00;
  712.   SD_SEND         = $01;
  713.   SD_BOTH         = $02;
  714.  
  715. { WinSock 2 extension -- data type and manifest constants for socket groups }
  716. type
  717.  
  718.   TGroup            = u_int;
  719.   PGroup           = ^TGroup;
  720.  
  721. const
  722.   
  723.   SG_UNCONSTRAINED_GROUP   = $01;
  724.   SG_CONSTRAINED_GROUP     = $02;
  725.  
  726. { WinSock 2 extension -- data type for WSAEnumNetworkEvents() }
  727.  
  728. type
  729.  
  730. PWSANETWORKEVENTS = ^TWSANETWORKEVENTS;
  731. TWSANETWORKEVENTS = packed record
  732.   lNetworkEvents           :u_long;
  733.   iErrorCode               : array [0..FD_MAX_EVENTS-1] of u_int;
  734. end;
  735.  
  736. {WinSock 2 extension -- WSAPROTOCOL_INFO structure and associated
  737.  manifest constants}
  738. { Removed this type as it is already declared in the COMOBJ unit. In any
  739.   case this version of TGUID for WS2 is NOT compatible with D3's definition
  740.   of TGUID!  JCP 271197 
  741. PGUID = ^TGUID;
  742.  
  743. TGUID = packed record
  744.   Data1              : u_long;
  745.   Data2              : u_short;
  746.   Data3              : u_short;
  747.   Data4              : array [0..8-1] of u_char;
  748. end;
  749. }
  750. const
  751.  
  752.   MAX_PROTOCOL_CHAIN  = 7;
  753.  
  754.   BASE_PROTOCOL       = 1;
  755.   LAYERED_PROTOCOL    = 0;
  756.  
  757. type
  758.  
  759. PWSAPROTOCOLCHAIN = ^TWSAPROTOCOLCHAIN;
  760. TWSAPROTOCOLCHAIN = packed record
  761.   ChainLen        : Integer;            { the length of the chain,     }
  762.                                         { length = 0 means layered protocol, }
  763.                                         { length = 1 means base protocol, }
  764.                                         { length > 1 means protocol chain }
  765.   ChainEntries : array[0..MAX_PROTOCOL_CHAIN-1] of DWORD; { a list of dwCatalogEntryIds }
  766. end;
  767.  
  768. const
  769.  
  770.   WSAPROTOCOL_LEN    = 255;
  771.  
  772. type
  773.   
  774. PWSAPROTOCOL_INFOA = ^TWSAPROTOCOL_INFOA;
  775. TWSAPROTOCOL_INFOA = packed record
  776.   dwServiceFlags1           : DWORD;
  777.   dwServiceFlags2           : DWORD;
  778.   dwServiceFlags3           : DWORD;
  779.   dwServiceFlags4           : DWORD;
  780.   dwProviderFlags           : DWORD;
  781.   ProviderId                : TGUID;
  782.   dwCatalogEntryId          : DWORD;
  783.   ProtocolChain             : TWSAPROTOCOLCHAIN;
  784.   iVersion                  : u_int;
  785.   iAddressFamily            : u_int;
  786.   iMaxSockAddr              : u_int;
  787.   iMinSockAddr              : u_int;
  788.   iSocketType               : u_int;
  789.   iProtocol                 : u_int;
  790.   iProtocolMaxOffset        : u_int;
  791.   iNetworkByteOrder         : u_int;
  792.   iSecurityScheme           : u_int;
  793.   dwMessageSize            : DWORD;
  794.   dwProviderReserved       : DWORD;
  795.   szProtocol               : array [0..WSAPROTOCOL_LEN+1-1] of u_char;
  796. end;
  797.  
  798. PWSAPROTOCOL_INFOW = ^TWSAPROTOCOL_INFOW;
  799. TWSAPROTOCOL_INFOW = packed record
  800.   dwServiceFlags1           : DWORD;
  801.   dwServiceFlags2           : DWORD;
  802.   dwServiceFlags3           : DWORD;
  803.   dwServiceFlags4           : DWORD;
  804.   dwProviderFlags           : DWORD;
  805.   ProviderId                : TGUID;
  806.   dwCatalogEntryId          : DWORD;
  807.   ProtocolChain             : TWSAPROTOCOLCHAIN;
  808.   iVersion                  : u_int;
  809.   iAddressFamily            : u_int;
  810.   iMaxSockAddr              : u_int;
  811.   iMinSockAddr              : u_int;
  812.   iSocketType               : u_int;
  813.   iProtocol                 : u_int;
  814.   iProtocolMaxOffset        : u_int;
  815.   iNetworkByteOrder         : u_int;
  816.   iSecurityScheme           : u_int;
  817.   dwMessageSize            : DWORD;
  818.   dwProviderReserved       : DWORD;
  819.   szProtocol               : array [0..WSAPROTOCOL_LEN+1-1] of WCHAR;
  820. end;
  821.  
  822. {$ifdef UNICODE}
  823.  
  824. TWSAPROTOCOL_INFO   =  TWSAPROTOCOL_INFOW ;
  825. PWSAPROTOCOL_INFO   =  PWSAPROTOCOL_INFOW ;
  826.  
  827. {$else}
  828.  
  829. TWSAPROTOCOL_INFO   =  TWSAPROTOCOL_INFOA ;
  830. PWSAPROTOCOL_INFO   =  PWSAPROTOCOL_INFOA ;
  831.  
  832. {$endif UNICODE}
  833.  
  834. const
  835. { Flag bit definitions for dwProviderFlags }
  836.  
  837.   PFL_MULTIPLE_PROTO_ENTRIES          =$00000001;
  838.   PFL_RECOMMENDED_PROTO_ENTRY         =$00000002;
  839.   PFL_HIDDEN                          =$00000004;
  840.   PFL_MATCHES_PROTOCOL_ZERO           =$00000008;
  841.  
  842. { Flag bit definitions for dwServiceFlags1 }
  843.   XP1_CONNECTIONLESS                  =$00000001;
  844.   XP1_GUARANTEED_DELIVERY             =$00000002;
  845.   XP1_GUARANTEED_ORDER                =$00000004;
  846.   XP1_MESSAGE_ORIENTED                =$00000008;
  847.   XP1_PSEUDO_STREAM                   =$00000010;
  848.   XP1_GRACEFUL_CLOSE                  =$00000020;
  849.   XP1_EXPEDITED_DATA                  =$00000040;
  850.   XP1_CONNECT_DATA                    =$00000080;
  851.   XP1_DISCONNECT_DATA                 =$00000100;
  852.   XP1_SUPPORT_BROADCAST               =$00000200;
  853.   XP1_SUPPORT_MULTIPOINT              =$00000400;
  854.   XP1_MULTIPOINT_CONTROL_PLANE        =$00000800;
  855.   XP1_MULTIPOINT_DATA_PLANE           =$00001000;
  856.   XP1_QOS_SUPPORTED                   =$00002000;
  857.   XP1_INTERRUPT                       =$00004000;
  858.   XP1_UNI_SEND                        =$00008000;
  859.   XP1_UNI_RECV                        =$00010000;
  860.   XP1_IFS_HANDLES                     =$00020000;
  861.   XP1_PARTIAL_MESSAGE                 =$00040000;
  862.  
  863.   BIGENDIAN                           =$0000;
  864.   LITTLEENDIAN                        =$0001;
  865.  
  866.   SECURITY_PROTOCOL_NONE              =$0000;
  867.  
  868. { WinSock 2 extension -- manifest constants for WSAJoinLeaf() }
  869.  
  870.   JL_SENDER_ONLY    =$01;
  871.   JL_RECEIVER_ONLY  =$02;
  872.   JL_BOTH           =$04;
  873.  
  874. { WinSock 2 extension -- manifest constants for WSASocket() }
  875.  
  876.   WSA_FLAG_OVERLAPPED           =$01;
  877.   WSA_FLAG_MULTIPOINT_C_ROOT    =$02;
  878.   WSA_FLAG_MULTIPOINT_C_LEAF    =$04;
  879.   WSA_FLAG_MULTIPOINT_D_ROOT    =$08;
  880.   WSA_FLAG_MULTIPOINT_D_LEAF    =$10;
  881.  
  882. { WinSock 2 extension -- manifest constants for WSAIoctl() }
  883.  
  884.   IOC_UNIX                      =$00000000;
  885.   IOC_WS2                       =$08000000;
  886.   IOC_PROTOCOL                  =$10000000;
  887.   IOC_VENDOR                    =$18000000;
  888.  
  889.   SIO_ASSOCIATE_HANDLE           = IOC_IN or IOC_WS2 or 1;
  890.   SIO_ENABLE_CIRCULAR_QUEUEING   = IOC_VOID or IOC_WS2 or 2;
  891.   SIO_FIND_ROUTE                 = IOC_OUT or IOC_WS2 or 3;
  892.   SIO_FLUSH                      = IOC_VOID or IOC_WS2 or 4;
  893.   SIO_GET_BROADCAST_ADDRESS      = IOC_OUT or IOC_WS2 or 5;
  894.   SIO_GET_EXTENSION_FUNCTION_POINTER  = IOC_INOUT or IOC_WS2 or 6;
  895.   SIO_GET_QOS                    = IOC_INOUT or IOC_WS2 or 7;
  896.   SIO_GET_GROUP_QOS              = IOC_INOUT or IOC_WS2 or 8;
  897.   SIO_MULTIPOINT_LOOPBACK        = IOC_IN or IOC_WS2 or 9;
  898.   SIO_MULTICAST_SCOPE            = IOC_IN or IOC_WS2 or 10;
  899.   SIO_SET_QOS                    = IOC_IN or IOC_WS2 or 11;
  900.   SIO_SET_GROUP_QOS              = IOC_IN or IOC_WS2 or 12;
  901.   SIO_TRANSLATE_HANDLE           = IOC_INOUT or IOC_WS2 or 13;
  902.  
  903. { WinSock 2 extension -- manifest constants for SIO_TRANSLATE_HANDLE ioctl }
  904.  
  905.   TH_NETDEV        = $00000001;
  906.   TH_TAPI          = $00000002;
  907.  
  908. {  Microsoft Windows Extended data types required for the functions to
  909.    convert   back  and  forth  between  binary  and  string  forms  of
  910.    addresses. }
  911.  
  912. type
  913.  
  914.   SOCKADDR     = TSockAddr; { AHS ?}
  915. {  PSOCKADDR    = PSockaddr;}
  916.   LPSOCKADDR   = PSockaddr;
  917.  
  918. { Manifest constants and type definitions related to name resolution and
  919.   registration (RNR) API }
  920.  
  921. PBLOB = ^TBLOB;
  922. TBLOB = packed record
  923.     cbSize    :ULONG;
  924.     pBlobData :^byte;
  925. end;
  926.  
  927. { Service Install Flags }
  928.  
  929. const
  930.  
  931.   SERVICE_MULTIPLE       =$00000001;
  932.  
  933. { Name Spaces }
  934.  
  935.   NS_ALL                      = 0;
  936.  
  937.   NS_SAP                      = 1;
  938.   NS_NDS                      = 2;
  939.   NS_PEER_BROWSE              = 3;
  940.  
  941.   NS_TCPIP_LOCAL              = 10;
  942.   NS_TCPIP_HOSTS              = 11;
  943.   NS_DNS                      = 12;
  944.   NS_NETBT                    = 13;
  945.   NS_WINS                     = 14;
  946.  
  947.   NS_NBP                      = 20;
  948.  
  949.   NS_MS                       = 30;
  950.   NS_STDA                     = 31;
  951.   NS_NTDS                     = 32;
  952.  
  953.   NS_X500                     = 40;
  954.   NS_NIS                      = 41;
  955.   NS_NISPLUS                  = 42;
  956.  
  957.   NS_WRQ                      = 50;
  958.  
  959.  
  960. {  Resolution flags for WSAGetAddressByName().
  961.    Note these are also used by the 1.1 API GetAddressByName, so
  962.    leave them around. }
  963.  
  964.   RES_UNUSED_1                =$00000001;
  965.   RES_FLUSH_CACHE             =$00000002;
  966.   RES_SERVICE                 =$00000004;
  967.  
  968.  
  969. { Well known value names for Service Types }
  970.  
  971.   SERVICE_TYPE_VALUE_IPXPORTA     ='IpxSocket';
  972.   SERVICE_TYPE_VALUE_IPXPORTW     = 'IpxSocket';
  973.   SERVICE_TYPE_VALUE_SAPIDA       = 'SapId';
  974.   SERVICE_TYPE_VALUE_SAPIDW       ='SapId';
  975.  
  976.   SERVICE_TYPE_VALUE_TCPPORTA     = 'TcpPort';
  977.   SERVICE_TYPE_VALUE_TCPPORTW     ='TcpPort';
  978.  
  979.   SERVICE_TYPE_VALUE_UDPPORTA     = 'UdpPort';
  980.   SERVICE_TYPE_VALUE_UDPPORTW     ='UdpPort';
  981.  
  982.   SERVICE_TYPE_VALUE_OBJECTIDA    = 'ObjectId';
  983.   SERVICE_TYPE_VALUE_OBJECTIDW    ='ObjectId';
  984.  
  985. {$ifdef UNICODE}
  986.  
  987.   SERVICE_TYPE_VALUE_SAPID        =SERVICE_TYPE_VALUE_SAPIDW;
  988.   SERVICE_TYPE_VALUE_TCPPORT      =SERVICE_TYPE_VALUE_TCPPORTW;
  989.   SERVICE_TYPE_VALUE_UDPPORT      =SERVICE_TYPE_VALUE_UDPPORTW;
  990.   SERVICE_TYPE_VALUE_OBJECTID     =SERVICE_TYPE_VALUE_OBJECTIDW;
  991.  
  992. {$else} { not UNICODE }
  993.  
  994.   SERVICE_TYPE_VALUE_SAPID        =SERVICE_TYPE_VALUE_SAPIDA;
  995.   SERVICE_TYPE_VALUE_TCPPORT      =SERVICE_TYPE_VALUE_TCPPORTA;
  996.   SERVICE_TYPE_VALUE_UDPPORT      =SERVICE_TYPE_VALUE_UDPPORTA;
  997.   SERVICE_TYPE_VALUE_OBJECTID     =SERVICE_TYPE_VALUE_OBJECTIDA;
  998.  
  999. {$endif}
  1000.  
  1001. { SockAddr Information }
  1002. type
  1003.  
  1004. PSOCKET_ADDRESS = ^TSOCKET_ADDRESS;
  1005. TSOCKET_ADDRESS = packed record
  1006.     lpSockaddr        :  PSOCKADDR ;
  1007.     iSockaddrLength   : u_int;
  1008. end;
  1009.  
  1010. { CSAddr Information }
  1011.  
  1012. PCSADDR_INFO = ^TCSADDR_INFO;
  1013. TCSADDR_INFO = packed record
  1014.     LocalAddr         :TSOCKET_ADDRESS;
  1015.     RemoteAddr        :TSOCKET_ADDRESS;
  1016.     iSocketType       :u_int;
  1017.     iProtocol         :u_int;
  1018. end;
  1019.  
  1020.  
  1021. { Address Family/Protocol Tuples }
  1022.  
  1023. PAFPROTOCOLS = ^TAFPROTOCOLS;
  1024. TAFPROTOCOLS = packed record
  1025.   iAddressFamily      :u_int;
  1026.   iProtocol           :u_int;
  1027. end;
  1028.  
  1029. { Client Query API Typedefs }
  1030.  
  1031. { The comparators }
  1032.  
  1033. PWSAEcomparator = ^TWSAEcomparator;
  1034. TWSAEcomparator = (
  1035.     COMP_EQUAL,
  1036.     COMP_NOTLESS
  1037. );
  1038.  
  1039. PWSAVersion = ^TWSAVersion;
  1040. TWSAVersion = packed record
  1041.     dwVersion        : Dword;
  1042.     ecHow            : TWSAEComparator;
  1043. end;
  1044.  
  1045. PWSAQuerySetA = ^TWSAQuerySetA;
  1046. TWSAQuerySetA = packed record
  1047.     dwSize                  : DWord;
  1048.     lpszServiceInstanceName : PChar;
  1049.     lpServiceClassId        : PGUID;
  1050.     lpVersion               : PWSAVERSION;
  1051.     lpszComment             : PChar;
  1052.     dwNameSpace             : DWord;
  1053.     lpNSProviderId          : PGUID;
  1054.     lpszContext             : PChar;
  1055.     dwNumberOfProtocols     : DWORD;
  1056.     lpafpProtocols          : PAFPROTOCOLS;
  1057.     lpszQueryString         : PChar;
  1058.     dwNumberOfCsAddrs       : Dword;
  1059.     lpcsaBuffer             : PCSADDR_INFO;
  1060.     dwOutputFlags           : DWord;
  1061.     lpBlob                  : PBLOB;
  1062. end;
  1063.  
  1064. PWSAQuerySetW = ^TWSAQuerySetW;
  1065. TWSAQuerySetW = packed record
  1066.     dwSize                  : DWord;
  1067.     lpszServiceInstanceName : WideChar;
  1068.     lpServiceClassId        : PGUID;
  1069.     lpVersion               : PWSAVERSION;
  1070.     lpszComment             : WideChar;
  1071.     dwNameSpace             : DWord;
  1072.     lpNSProviderId          : PGUID;
  1073.     lpszContext             : WideChar;
  1074.     dwNumberOfProtocols     : DWORD;
  1075.     lpafpProtocols          : PAFPROTOCOLS;
  1076.     lpszQueryString         : WideChar;
  1077.     dwNumberOfCsAddrs       : Dword;
  1078.     lpcsaBuffer             : PCSADDR_INFO;
  1079.     dwOutputFlags           : DWord;
  1080.     lpBlob                  : PBLOB;
  1081. end;
  1082.  
  1083. {$ifdef UNICODE}
  1084.  
  1085.   WSAQUERYSET              = TWSAQUERYSETW;
  1086.   PWSAQUERYSET             = PWSAQUERYSETW;
  1087.  
  1088. {$else}
  1089.  
  1090.   WSAQUERYSET              = TWSAQUERYSETA;
  1091.   PWSAQUERYSET             = PWSAQUERYSETA;
  1092.  
  1093. {$endif }
  1094.  
  1095. const
  1096.  
  1097.   LUP_DEEP                = $0001;
  1098.   LUP_CONTAINERS          = $0002;
  1099.   LUP_NOCONTAINERS        = $0004;
  1100.   LUP_NEAREST             = $0008;
  1101.   LUP_RETURN_NAME         = $0010;
  1102.   LUP_RETURN_TYPE         = $0020;
  1103.   LUP_RETURN_VERSION      = $0040;
  1104.   LUP_RETURN_COMMENT      = $0080;
  1105.   LUP_RETURN_ADDR         = $0100;
  1106.   LUP_RETURN_BLOB         = $0200;
  1107.   LUP_RETURN_ALIASES      = $0400;
  1108.   LUP_RETURN_QUERY_STRING = $0800;
  1109.   LUP_RETURN_ALL          = $0FF0;
  1110.   LUP_RES_SERVICE         = $8000;
  1111.  
  1112.   LUP_FLUSHCACHE       = $1000;
  1113.   LUP_FLUSHPREVIOUS    = $2000;
  1114.  
  1115.  
  1116. { Return flags }
  1117.  
  1118.   RESULT_IS_ALIAS      = $0001;
  1119.  
  1120. { Service Address Registration and Deregistration Data Types. }
  1121.  
  1122. type
  1123.  
  1124. PWSAESETSERVICEOP = ^TWSAESETSERVICEOP;
  1125. TWSAESETSERVICEOP = (
  1126.     RNRSERVICE_REGISTER,
  1127.     RNRSERVICE_DEREGISTER,
  1128.     RNRSERVICE_DELETE
  1129. );
  1130.  
  1131. { Service Installation/Removal Data Types. }
  1132.  
  1133. PWSANSClassInfoA = ^TWSANSClassInfoA;
  1134. TWSANSClassInfoA = packed record
  1135.   lpszName         : PChar;
  1136.   dwNameSpace      : Dword;
  1137.   dwValueType      : Dword;
  1138.   dwValueSize      : Dword;
  1139.   lpValue          : Pointer;
  1140.  end;
  1141.  
  1142. PWSANSClassInfoW = ^TWSANSClassInfoW;
  1143. TWSANSClassInfoW = packed record
  1144.   lpszName         : WideChar;
  1145.   dwNameSpace      : Dword;
  1146.   dwValueType      : Dword;
  1147.   dwValueSize      : Dword;
  1148.   lpValue          : Pointer;
  1149.  end;
  1150.  
  1151. {$ifdef UNICODE }
  1152.  
  1153.   TWSANSCLASSINFO   = TWSANSCLASSINFOW;
  1154.   PWSANSCLASSINFO  = PWSANSCLASSINFOW;
  1155.  
  1156. {$else}
  1157.  
  1158.   TWSANSCLASSINFO   = TWSANSCLASSINFOA;
  1159.   PWSANSCLASSINFO  = PWSANSCLASSINFOA;
  1160.  
  1161. {$endif  UNICODE}
  1162.  
  1163. PWSAServiceClassInfoA = ^TWSAServiceClassInfoA;
  1164. TWSAServiceClassInfoA = packed record
  1165.     lpServiceClassId      : PGUID;
  1166.     lpszServiceClassName  : PChar;
  1167.     dwCount               : DWord;
  1168.     lpClassInfos          : PWSANSCLASSINFOA;
  1169. end;
  1170.  
  1171. PWSAServiceClassInfoW = ^TWSAServiceClassInfoW;
  1172. TWSAServiceClassInfoW = packed record
  1173.     lpServiceClassId      : PGUID;
  1174.     lpszServiceClassName  : WideChar;
  1175.     dwCount               : DWord;
  1176.     lpClassInfos          : PWSANSCLASSINFOW;
  1177. end;
  1178.  
  1179. {$ifdef UNICODE}
  1180.  
  1181.   TWSASERVICECLASSINFO         = TWSASERVICECLASSINFOW;
  1182.   PWSASERVICECLASSINFO        = PWSASERVICECLASSINFOW;
  1183.  
  1184. {$else}
  1185.  
  1186.   TWSASERVICECLASSINFO         = TWSASERVICECLASSINFOA;
  1187.   PWSASERVICECLASSINFO        = PWSASERVICECLASSINFOA;
  1188.  
  1189. {$endif  UNICODE}
  1190.  
  1191. PWSANAMESPACE_INFOA = ^TWSANAMESPACE_INFOA;
  1192. TWSANAMESPACE_INFOA = packed record
  1193.     NSProviderId      : TGUID;
  1194.     dwNameSpace       : DWord;
  1195.     fActive           : BOOL;
  1196.     dwVersion         : DWord;
  1197.     lpszIdentifier    : PChar;
  1198. end;
  1199.  
  1200. PWSANAMESPACE_INFOW = ^TWSANAMESPACE_INFOW;
  1201. TWSANAMESPACE_INFOW = packed record
  1202.     NSProviderId      : TGUID;
  1203.     dwNameSpace       : DWord;
  1204.     fActive           : BOOL;
  1205.     dwVersion         : DWord;
  1206.     lpszIdentifier    : WideChar;
  1207. end;
  1208.  
  1209. {$ifdef UNICODE}
  1210.  
  1211.   TWSANAMESPACE_INFO     = TWSANAMESPACE_INFOW;
  1212.   PWSANAMESPACE_INFO     = PWSANAMESPACE_INFOW;
  1213.  
  1214. {$else}
  1215.  
  1216.   TWSANAMESPACE_INFO     = TWSANAMESPACE_INFOA;
  1217.   PWSANAMESPACE_INFO     = PWSANAMESPACE_INFOA;
  1218.  
  1219. {$endif  UNICODE}
  1220.  
  1221. { AHS END }
  1222.  
  1223. { Socket function prototypes }
  1224.  
  1225. function accept(s: TSocket; var addr: TSockAddr; var addrlen: Integer): TSocket; stdcall;
  1226. function bind(s: TSocket; var addr: TSockAddr; namelen: Integer): Integer; stdcall;
  1227. function closesocket(s: TSocket): Integer; stdcall;
  1228. function connect(s: TSocket; var name: TSockAddr; namelen: Integer): Integer; stdcall;
  1229. function ioctlsocket(s: TSocket; cmd: Longint; var arg: u_long): Integer; stdcall;
  1230. function getpeername(s: TSocket; var name: TSockAddr; var namelen: Integer): Integer; stdcall;
  1231. function getsockname(s: TSocket; var name: TSockAddr; var namelen: Integer): Integer; stdcall;
  1232. function getsockopt(s: TSocket; level, optname: Integer; optval: PChar; var optlen: Integer): Integer; stdcall;
  1233. function htonl(hostlong: u_long): u_long; stdcall;
  1234. function htons(hostshort: u_short): u_short; stdcall;
  1235. function inet_addr(cp: PChar): u_long; stdcall; {PInAddr;}  { TInAddr }
  1236. function inet_ntoa(inaddr: TInAddr): PChar; stdcall;
  1237. function listen(s: TSocket; backlog: Integer): Integer; stdcall;
  1238. function ntohl(netlong: u_long): u_long; stdcall;
  1239. function ntohs(netshort: u_short): u_short; stdcall;
  1240. function recv(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;
  1241. function recvfrom(s: TSocket; var Buf; len, flags: Integer;
  1242.   var from: TSockAddr; var fromlen: Integer): Integer; stdcall;
  1243. function select(nfds: Integer; readfds, writefds, exceptfds: PFDSet;
  1244.   timeout: PTimeVal): Longint; stdcall;
  1245. function send(s: TSocket; var Buf; len, flags: Integer): Integer; stdcall;
  1246. function sendto(s: TSocket; var Buf; len, flags: Integer; var addrto: TSockAddr;
  1247.   tolen: Integer): Integer; stdcall;
  1248. function setsockopt(s: TSocket; level, optname: Integer; optval: PChar;
  1249.   optlen: Integer): Integer; stdcall;
  1250. function shutdown(s: TSocket; how: Integer): Integer; stdcall;
  1251. function socket(af, struct, protocol: Integer): TSocket; stdcall;
  1252. function gethostbyaddr(addr: Pointer; len, struct: Integer): PHostEnt; stdcall;
  1253. function gethostbyname(name: PChar): PHostEnt; stdcall;
  1254. function gethostname(name: PChar; len: Integer): Integer; stdcall;
  1255. function getservbyport(port: Integer; proto: PChar): PServEnt; stdcall;
  1256. function getservbyname(name, proto: PChar): PServEnt; stdcall;
  1257. function getprotobynumber(proto: Integer): PProtoEnt; stdcall;
  1258. function getprotobyname(name: PChar): PProtoEnt; stdcall;
  1259. function WSAStartup(wVersionRequired: word; var WSData: TWSAData): Integer; stdcall;
  1260. function WSACleanup: Integer; stdcall;
  1261. procedure WSASetLastError(iError: Integer); stdcall;
  1262. function WSAGetLastError: Integer; stdcall;
  1263. function WSAIsBlocking: BOOL; stdcall;
  1264. function WSAUnhookBlockingHook: Integer; stdcall;
  1265. function WSASetBlockingHook(lpBlockFunc: TFarProc): TFarProc; stdcall;
  1266. function WSACancelBlockingCall: Integer; stdcall;
  1267. function WSAAsyncGetServByName(HWindow: HWND; wMsg: u_int;
  1268.   name, proto, buf: PChar; buflen: Integer): THandle; stdcall;
  1269. function WSAAsyncGetServByPort( HWindow: HWND; wMsg, port: u_int;
  1270.   proto, buf: PChar; buflen: Integer): THandle; stdcall;
  1271. function WSAAsyncGetProtoByName(HWindow: HWND; wMsg: u_int;
  1272.   name, buf: PChar; buflen: Integer): THandle; stdcall;
  1273. function WSAAsyncGetProtoByNumber(HWindow: HWND; wMsg: u_int; number: Integer;
  1274.   buf: PChar; buflen: Integer): THandle; stdcall;
  1275. function WSAAsyncGetHostByName(HWindow: HWND; wMsg: u_int;
  1276.   name, buf: PChar; buflen: Integer): THandle; stdcall;
  1277. function WSAAsyncGetHostByAddr(HWindow: HWND; wMsg: u_int; addr: PChar;
  1278.   len, struct: Integer; buf: PChar; buflen: Integer): THandle; stdcall;
  1279. function WSACancelAsyncRequest(hAsyncTaskHandle: THandle): Integer; stdcall;
  1280. function WSAAsyncSelect(s: TSocket; HWindow: HWND; wMsg: u_int; lEvent: Longint): Integer; stdcall;
  1281.  
  1282. { WinSock 2 extensions -- data types for the condition function in
  1283.   WSAAccept() and overlapped I/O completion routine. }
  1284.  
  1285. type
  1286.  
  1287. PCONDITIONPROC = function ( lpCallerId:PWSABUF; lpCallerData:PWSABUF;
  1288.     lpSQOS:PQOS; lpGQOS:PQOS; lpCalleeId:PWSABUF;lpCalleeData:PWSABUF;
  1289.     g:PGroup; dwCallbackData:DWord) :u_int; stdcall;
  1290.  
  1291. PWSAOVERLAPPED_COMPLETION_ROUTINE = procedure ( dwError :Dword;
  1292.     cbTransferred: DWORD; lpOverlapped: LPWSAOVERLAPPED; dwFlags: Dword
  1293.     ); stdcall;
  1294.  
  1295. { WinSock 2 API new function prototypes }
  1296.  
  1297. function WSAAccept( s: TSOCKET; addr: psockaddr; addrlen: PINT;
  1298.     lpfnCondition: PCONDITIONPROC; dwCallbackData: DWORD): TSOCKET; stdcall;
  1299. function WSACloseEvent( hEvent: WSAEVENT ):BOOL; stdcall;
  1300. function WSAConnect(s: TSOCKET; name: psockaddr;namelen: u_int;
  1301.     lpCallerData: PWSABUF; lpCalleeData: PWSABUF; lpSQOS: PQOS;
  1302.     lpGQOS: PQOS) : u_int; stdcall;
  1303. function WSACreateEvent:WSAEVENT; stdcall;
  1304.  
  1305. {$IFDEF UNICODE}
  1306. function WSADuplicateSocket(s: TSocket; dwProcessId: DWORD;
  1307.    lpProtocolInfo: PWSAPROTOCOL_INFOW): u_int; stdcall;
  1308. {$ELSE}
  1309. function WSADuplicateSocket(s: TSocket; dwProcessId: DWORD;
  1310.    lpProtocolInfo: PWSAPROTOCOL_INFOA): u_int; stdcall;
  1311. {$ENDIF} {UNICODE}
  1312.  
  1313. function WSAEnumNetworkEvents( s: TSocket; hEventObject: WSAEVENT;
  1314.    lpNetworkEvents: PWSANETWORKEVENTS): u_int; stdcall;
  1315.  
  1316. {$IFDEF UNICODE}
  1317. function WSAEnumProtocols( lpiProtocols: PInt;
  1318.    lpProtocolBuffer: PWSAPROTOCOL_INFOW; lpdwBufferLength: PDWORD
  1319.    ): u_int; stdcall;
  1320. {$ELSE}
  1321. function WSAEnumProtocols( lpiProtocols: PInt;
  1322.    lpProtocolBuffer: PWSAPROTOCOL_INFOA; lpdwBufferLength: PDWORD
  1323.    ): u_int; stdcall;
  1324. {$ENDIF} {UNICODE}
  1325.  
  1326. function WSAEventSelect(s: TSOCKET; hEventObject: WSAEVENT;
  1327.     lNetworkEvents: u_long): u_int; stdcall;
  1328. function WSAGetOverlappedResult( s: TSocket; lpOverlapped: LPWSAOVERLAPPED;
  1329.     lpcbTransfer: PDWORD; fWait: BOOL; lpdwFlags: PDWORD): BOOL; stdcall;
  1330. function WSAGetQOSByName( s: TSocket; lpQOSName: PWSABUF;
  1331.     lpQOS: PQOS): BOOL; stdcall;
  1332. function WSAHtonl( s: TSocket; hostlong: u_long; lpnetlong: pu_long)
  1333.     : u_int; stdcall;
  1334. function WSAHtons( s: TSocket; hostshort: u_short; lpnetshort: pu_short)
  1335.     : u_int; stdcall;
  1336. function WSAIoctl( s: TSocket; dwIoControlCode: DWORD; lpvInBuffer: Pointer;
  1337.     cbInBuffer: DWORD; lpvOutBuffer: Pointer; cbOutBuffer: DWORD;
  1338.     lpcbBytesReturned: PDWORD; lpOverlapped: LPWSAOVERLAPPED;
  1339.     lpCompletionRoutine: PWSAOVERLAPPED_COMPLETION_ROUTINE): u_int; stdcall;
  1340. function WSAJoinLeaf( s: TSocket; name: psockaddr; namelen: u_int;
  1341.     lpCallerData: PWSABUF; lpCalleeData: PWSABUF; lpSQOS: PQOS; lpGQOS: PQOS;
  1342.     dwFlags: DWORD): TSocket; stdcall;
  1343. function WSANtohl( s: TSocket; netlong: u_long; lphostlong: pu_long)
  1344.     : u_int; stdcall;
  1345. function WSANtohs( s: TSocket; netshort: u_short; lphostshort: pu_short)
  1346.     : u_int; stdcall;
  1347. function WSARecv( s: TSocket; lpBuffers: PWSABUF; dwBufferCount: DWORD;
  1348.     lpNumberOfBytesRecvd: PDWORD; lpFlags: PDWORD;lpOverlapped: LPWSAOVERLAPPED;
  1349.     lpCompletionRoutine: PWSAOVERLAPPED_COMPLETION_ROUTINE): u_int; stdcall;
  1350. function WSARecvDisconnect( s: TSocket; lpInboundDisconnectData: PWSABUF)
  1351.     : u_int; stdcall;
  1352. function WSARecvFrom( s: TSocket; lpBuffers: PWSABUF; dwBufferCount: DWORD;
  1353.     lpNumberOfBytesRecvd: PDWORD; lpFlags: PDWORD; lpFrom: psockaddr;
  1354.     lpFromlen: PInt; lpOverlapped: LPWSAOVERLAPPED;
  1355.     lpCompletionRoutine: PWSAOVERLAPPED_COMPLETION_ROUTINE): u_int; stdcall;
  1356. function WSAResetEvent( hEvent: WSAEVENT): BOOL; stdcall;
  1357. function WSASend( s: TSocket; lpBuffers: PWSABUF; dwBufferCount: DWORD;
  1358.     lpNumberOfBytesSent: PDWORD; dwFlags: DWORD; lpOverlapped: LPWSAOVERLAPPED;
  1359.     lpCompletionRoutine: PWSAOVERLAPPED_COMPLETION_ROUTINE): u_int; stdcall;
  1360. function WSASendDisconnect( s: TSocket; lpOutboundDisconnectData: PWSABUF)
  1361.     : u_int; stdcall;
  1362. function WSASendTo(s: TSocket; lpBuffers: PWSABUF; dwBufferCount: DWORD;
  1363.     lpNumberOfBytesSent: PDWORD;dwFlags: DWORD; lpTo: psockaddr; iTolen: u_int;
  1364.     lpOverlapped: LPWSAOVERLAPPED;
  1365.     lpCompletionRoutine: PWSAOVERLAPPED_COMPLETION_ROUTINE): u_int; stdcall;
  1366. function WSASetEvent( hEvent: WSAEVENT): BOOL; stdcall;
  1367. {$IFDEF UNICODE}
  1368. function WSASocket( af: u_int; atype: u_int; protocol: u_int;
  1369.     lpProtocolInfo: PWSAPROTOCOL_INFOW; g: TGroup; dwFlags: Dword)
  1370.     : TSocket; stdcall;
  1371. {$ELSE}
  1372. function WSASocket( af: u_int; atype: u_int; protocol: u_int;
  1373.     lpProtocolInfo: PWSAPROTOCOL_INFOA; g: TGroup; dwFlags: Dword)
  1374.     : TSocket; stdcall;
  1375. {$ENDIF} { UNICODE}
  1376. function WSAWaitForMultipleEvents( cEvents: DWORD; lphEvents: LPWSAEVENT;
  1377.     fWaitAll: BOOL; dwTimeout: DWORD; fAlertable: BOOL): DWORD; stdcall;
  1378. {$IFDEF UNICODE}
  1379. function WSAAddressToString( lpsaAddress: PSOCKADDR; dwAddressLength: DWORD;
  1380.     lpProtocolInfo: PWSAPROTOCOL_INFOW; lpszAddressString: WideChar;
  1381.     lpdwAddressStringLength: PDWORD): u_int; stdcall;
  1382. {$ELSE}
  1383. function WSAAddressToString( lpsaAddress: PSOCKADDR; dwAddressLength: DWORD;
  1384.     lpProtocolInfo: PWSAPROTOCOL_INFOA; lpszAddressString: PChar;
  1385.     lpdwAddressStringLength: PDWORD): u_int; stdcall;
  1386. {$ENDIF} { UNICODE}
  1387.  
  1388. {$IFDEF UNICODE}
  1389. function WSAStringToAddress( AddressString: WideChar; AddressFamily: u_int;
  1390.     lpProtocolInfo: PWSAPROTOCOL_INFOW; lpAddress: PSOCKADDR;
  1391.     lpAddressLength: PInt): u_int; stdcall;
  1392. {$ELSE}
  1393. function WSAStringToAddress( AddressString: PChar; AddressFamily: u_int;
  1394.     lpProtocolInfo: PWSAPROTOCOL_INFOA; lpAddress: PSOCKADDR;
  1395.     lpAddressLength: PInt): u_int; stdcall;
  1396. {$ENDIF} { UNICODE}
  1397.  
  1398. { Registration and Name Resolution API functions }
  1399.  
  1400. {$IFDEF UNICODE}
  1401. function WSALookupServiceBegin( lpqsRestrictions: PWSAQUERYSETW;
  1402.     dwControlFlags: DWORD; lphLookup: LPHANDLE): u_int; stdcall;
  1403. {$ELSE}
  1404. function WSALookupServiceBegin( lpqsRestrictions: PWSAQUERYSETA;
  1405.     dwControlFlags: DWORD; lphLookup: LPHANDLE): u_int; stdcall;
  1406. {$ENDIF} { UNICODE}
  1407.  
  1408. {$IFDEF UNICODE}
  1409. function WSALookupServiceNext( hLookup: THANDLE; dwControlFlags: DWORD;
  1410.     lpdwBufferLength: PDWORD; lpqsResults: PWSAQUERYSETW): u_int; stdcall;
  1411. {$ELSE}
  1412. function WSALookupServiceNext( hLookup: THANDLE; dwControlFlags: DWORD;
  1413.     lpdwBufferLength: PDWORD; lpqsResults: PWSAQUERYSETA): LongInt; stdcall;
  1414. {$ENDIF} { UNICODE}
  1415.  
  1416. function WSALookupServiceEnd( hLookup: THandle): u_int; stdcall;
  1417.  
  1418. {$IFDEF UNICODE}
  1419. function WSAInstallServiceClass( lpServiceClassInfo: PWSASERVICECLASSINFOW
  1420.     ): u_int; stdcall;
  1421. {$ELSE}
  1422. function WSAInstallServiceClass( lpServiceClassInfo: PWSASERVICECLASSINFOA
  1423.     ): u_int; stdcall;
  1424. {$ENDIF} { UNICODE}
  1425.  
  1426. function WSARemoveServiceClass(lpServiceClassId: PGUID): u_int; stdcall;
  1427.  
  1428. {$IFDEF UNICODE}
  1429. function WSAGetServiceClassInfo( lpProviderId: PGUID; lpServiceClassId: PGUID;
  1430.     lpdwBufSize: PDWORD; lpServiceClassInfo: PWSASERVICECLASSINFOW)
  1431.     : u_int; stdcall;
  1432. {$ELSE}
  1433. function WSAGetServiceClassInfo( lpProviderId: PGUID; lpServiceClassId: PGUID;
  1434.     lpdwBufSize: PDWORD; lpServiceClassInfo: PWSASERVICECLASSINFOA)
  1435.     : u_int; stdcall;
  1436. {$ENDIF} { UNICODE}
  1437.  
  1438. {$IFDEF UNICODE}
  1439. function WSAEnumNameSpaceProviders( lpdwBufferLength: PDWORD;
  1440.     lpnspBuffer: PWSANAMESPACE_INFOW):u_int; stdcall;
  1441. {$ELSE}
  1442. function WSAEnumNameSpaceProviders( lpdwBufferLength: PDWORD;
  1443.     lpnspBuffer: PWSANAMESPACE_INFOA):u_int; stdcall;
  1444. {$ENDIF} { UNICODE}
  1445.  
  1446. {$IFDEF UNICODE}
  1447. function WSAGetServiceClassNameByClassId( lpServiceClassId: PGUID;
  1448.     lpszServiceClassName: WideChar; lpdwBufferLength: PDWORD): u_int; stdcall;
  1449. {$ELSE}
  1450. function WSAGetServiceClassNameByClassId( lpServiceClassId: PGUID;
  1451.     lpszServiceClassName: PChar; lpdwBufferLength: PDWORD): u_int; stdcall;
  1452. {$ENDIF} { UNICODE}
  1453.  
  1454. {$IFDEF UNICODE}
  1455. function WSASetService( lpqsRegInfo: PWSAQUERYSETW;
  1456.     essoperation: TWSAESETSERVICEOP; dwControlFlags: DWORD):u_int; stdcall;
  1457. {$ELSE}
  1458. function WSASetService( lpqsRegInfo: PWSAQUERYSETA;
  1459.     essoperation: TWSAESETSERVICEOP; dwControlFlags: DWORD):u_int; stdcall;
  1460. {$ENDIF} { UNICODE}
  1461.  
  1462. function WSARecvEx(s: TSocket; var buf; len: Integer; var flags: Integer): Integer; stdcall;
  1463.  
  1464. function TransmitFile(hSocket: TSocket; hFile: THandle; nNumberOfBytesToWrite: DWORD;
  1465.   nNumberOfBytesPerSend: DWORD; lpOverlapped: POverlapped;
  1466.   lpTransmitBuffers: PTransmitFileBuffers; dwReserved: DWORD): BOOL; stdcall;
  1467.  
  1468. function WSAMakeASyncReply(Buflen, Error: Word): Longint;
  1469. function WSAMakeSelectReply(Event, Error: Word): Longint;
  1470. function WSAGetAsyncBuflen(Param: Longint): Word;
  1471. function WSAGetAsyncError(Param: Longint): Word;
  1472. function WSAGetSelectEvent(Param: Longint): Word;
  1473. function WSAGetSelectError(Param: Longint): Word;
  1474.  
  1475. implementation
  1476.  
  1477. const
  1478.   winsocket = 'ws2_32.dll';
  1479.  
  1480. function WSAMakeASyncReply;
  1481. begin
  1482.   WSAMakeASyncReply:= MakeLong(Buflen, Error);
  1483. end;
  1484.  
  1485. function WSAMakeSelectReply;
  1486. begin
  1487.   WSAMakeSelectReply:= MakeLong(Event, Error);
  1488. end;
  1489.  
  1490. function WSAGetAsyncBuflen;
  1491. begin
  1492.   WSAGetAsyncBuflen:= LOWORD(Param);
  1493. end;
  1494.  
  1495. function WSAGetAsyncError;
  1496. begin
  1497.   WSAGetAsyncError:= HIWORD(Param);
  1498. end;
  1499.  
  1500. function WSAGetSelectEvent;
  1501. begin
  1502.   WSAGetSelectEvent:= LOWORD(Param);
  1503. end;
  1504.  
  1505. function WSAGetSelectError;
  1506. begin
  1507.   WSAGetSelectError:= HIWORD(Param);
  1508. end;
  1509.  
  1510. function accept;
  1511.          external    winsocket name 'accept';
  1512. function bind;
  1513.          external    winsocket name 'bind';
  1514. function closesocket;
  1515.          external    winsocket name 'closesocket';
  1516. function connect;
  1517.          external    winsocket name 'connect';
  1518. function getpeername;
  1519.          external    winsocket name 'getpeername';
  1520. function getsockname;
  1521.          external    winsocket name 'getsockname';
  1522. function getsockopt;
  1523.          external    winsocket name 'getsockopt';
  1524. function htonl;
  1525.          external    winsocket name 'htonl';
  1526. function htons;
  1527.          external    winsocket name 'htons';
  1528. function inet_addr;
  1529.          external    winsocket name 'inet_addr';
  1530. function inet_ntoa;
  1531.          external    winsocket name 'inet_ntoa';
  1532. function ioctlsocket;
  1533.          external    winsocket name 'ioctlsocket';
  1534. function listen;
  1535.          external    winsocket name 'listen';
  1536. function ntohl;
  1537.          external    winsocket name 'ntohl';
  1538. function ntohs;
  1539.          external    winsocket name 'ntohs';
  1540. function recv;
  1541.          external    winsocket name 'recv';
  1542. function recvfrom;
  1543.          external    winsocket name 'recvfrom';
  1544. function select;
  1545.          external    winsocket name 'select';
  1546. function send;
  1547.          external    winsocket name 'send';
  1548. function sendto;
  1549.          external    winsocket name 'sendto';
  1550. function setsockopt;
  1551.          external    winsocket name 'setsockopt';
  1552. function shutdown;
  1553.          external    winsocket name 'shutdown';
  1554. function socket;
  1555.          external    winsocket name 'socket';
  1556.  
  1557. function gethostbyaddr;
  1558.          external    winsocket name 'gethostbyaddr';
  1559. function gethostbyname;
  1560.          external    winsocket name 'gethostbyname';
  1561. function getprotobyname;
  1562.          external    winsocket name 'getprotobyname';
  1563. function getprotobynumber;
  1564.          external    winsocket name 'getprotobynumber';
  1565. function getservbyname;
  1566.          external    winsocket name 'getservbyname';
  1567. function getservbyport;
  1568.          external    winsocket name 'getservbyport';
  1569. function gethostname;
  1570.          external    winsocket name 'gethostname';
  1571.  
  1572. function WSAAsyncSelect;
  1573.          external    winsocket name 'WSAAsyncSelect';
  1574. function WSARecvEx;
  1575.          external    winsocket name 'WSARecvEx';
  1576. function WSAAsyncGetHostByAddr;
  1577.          external winsocket name 'WSAAsyncGetHostByAddr';
  1578. function WSAAsyncGetHostByName;
  1579.          external winsocket name 'WSAAsyncGetHostByName';
  1580. function WSAAsyncGetProtoByNumber;
  1581.          external winsocket name 'WSAAsyncGetProtoByNumber';
  1582. function WSAAsyncGetprotoByName;
  1583.          external winsocket name 'WSAAsyncGetprotoByName';
  1584. function WSAAsyncGetServByPort;
  1585.          external winsocket name 'WSAAsyncGetServByPort';
  1586. function WSAAsyncGetServByName;
  1587.          external winsocket name 'WSAAsyncGetServByName';
  1588. function WSACancelAsyncRequest;
  1589.          external winsocket name 'WSACancelAsyncRequest';
  1590. function WSASetBlockingHook;
  1591.          external    winsocket name 'WSASetBlockingHook';
  1592. function WSAUnhookBlockingHook;
  1593.          external winsocket name 'WSAUnhookBlockingHook';
  1594. function WSAGetLastError;
  1595.          external    winsocket name 'WSAGetLastError';
  1596. procedure WSASetLastError;
  1597.          external    winsocket name 'WSASetLastError';
  1598. function WSACancelBlockingCall;
  1599.          external winsocket name 'WSACancelBlockingCall';
  1600. function WSAIsBlocking;
  1601.          external     winsocket name 'WSAIsBlocking';
  1602. function WSAStartup;
  1603.          external     winsocket name 'WSAStartup';
  1604. function WSACleanup;
  1605.          external     winsocket name 'WSACleanup';
  1606.  
  1607. {$IFDEF UNICODE}
  1608. function WSASetService;
  1609.          external     winsocket name 'WSASetServiceW';
  1610. function WSAGetServiceClassNameByClassId;
  1611.          external     winsocket name 'WSAGetServiceClassNameByClassIdW';
  1612. function WSAEnumNameSpaceProviders;
  1613.          external     winsocket name 'WSAEnumNameSpaceProvidersW';
  1614. function WSAGetServiceClassInfo;
  1615.          external     winsocket name 'WSAGetServiceClassInfoW';
  1616. function WSAInstallServiceClass;
  1617.          external     winsocket name 'WSAInstallServiceClassW';
  1618. function WSALookupServiceNext;
  1619.          external     winsocket name 'WSALookupServiceNextW';
  1620. function WSALookupServiceBegin;
  1621.          external     winsocket name 'WSALookupServiceBeginW';
  1622. function WSAStringToAddress;
  1623.          external     winsocket name 'WSAStringToAddressW';
  1624. function WSAAddressToString;
  1625.          external     winsocket name 'WSAAddressToStringW';
  1626. function WSASocket;
  1627.          external     winsocket name 'WSASocketW';
  1628. function WSAEnumProtocols;
  1629.          external     winsocket name 'WSAEnumProtocolsW';
  1630. function WSADuplicateSocket;
  1631.          external     winsocket name 'WSADuplicateSocketW';
  1632. {$ELSE}
  1633. function WSASetService;
  1634.          external     winsocket name 'WSASetServiceA';
  1635. function WSAGetServiceClassNameByClassId;
  1636.          external     winsocket name 'WSAGetServiceClassNameByClassIdA';
  1637. function WSAEnumNameSpaceProviders;
  1638.          external     winsocket name 'WSAEnumNameSpaceProvidersA';
  1639. function WSAGetServiceClassInfo;
  1640.          external     winsocket name 'WSAGetServiceClassInfoA';
  1641. function WSAInstallServiceClass;
  1642.          external     winsocket name 'WSAInstallServiceClassA';
  1643. function WSALookupServiceNext;
  1644.          external     winsocket name 'WSALookupServiceNextA';
  1645. function WSALookupServiceBegin;
  1646.          external     winsocket name 'WSALookupServiceBeginA';
  1647. function WSAStringToAddress;
  1648.          external     winsocket name 'WSAStringToAddressA';
  1649. function WSAAddressToString;
  1650.          external     winsocket name 'WSAAddressToStringA';
  1651. function WSASocket;
  1652.          external     winsocket name 'WSASocketA';
  1653. function WSAEnumProtocols;
  1654.          external     winsocket name 'WSAEnumProtocolsA';
  1655. function WSADuplicateSocket;
  1656.          external     winsocket name 'WSADuplicateSocketA';
  1657. {$ENDIF} { UNICODE}
  1658.  
  1659.  
  1660. function WSALookupServiceEnd;
  1661.          external     winsocket name 'WSALookupServiceEnd';
  1662. function WSARemoveServiceClass;
  1663.          external     winsocket name 'WSARemoveServiceClass';
  1664. function WSAWaitForMultipleEvents;
  1665.          external     winsocket name 'WSAWaitForMultipleEvents';
  1666. function WSASetEvent;
  1667.          external     winsocket name 'WSASetEvent';
  1668. function WSASendTo;
  1669.          external     winsocket name 'WSASendTo';
  1670. function WSASendDisconnect;
  1671.          external     winsocket name 'WSASendDisconnect';
  1672. function WSASend;
  1673.          external     winsocket name 'WSASend';
  1674. function WSAResetEvent;
  1675.          external     winsocket name 'WSAResetEvent';
  1676. function WSARecvFrom;
  1677.          external     winsocket name 'WSARecvFrom';
  1678. function WSARecvDisconnect;
  1679.          external     winsocket name 'WSARecvDisconnect';
  1680. function WSARecv;
  1681.          external     winsocket name 'WSARecv';
  1682. function WSAIoctl;
  1683.          external     winsocket name 'WSAIoctl';
  1684. function WSAJoinLeaf;
  1685.          external     winsocket name 'WSAJoinLeaf';
  1686. function WSANtohl;
  1687.          external     winsocket name 'WSANtohl';
  1688. function WSANtohs;
  1689.          external     winsocket name 'WSANtohs';
  1690. function WSAHtons;
  1691.          external     winsocket name 'WSAHtons';
  1692. function WSAHtonl;
  1693.          external     winsocket name 'WSAHtonl';
  1694. function WSAGetQOSByName;
  1695.          external     winsocket name 'WSAGetQOSByName';
  1696. function WSAGetOverlappedResult;
  1697.          external     winsocket name 'WSAGetOverlappedResult';
  1698. function WSAEventSelect;
  1699.          external     winsocket name 'WSAEventSelect';
  1700. function WSAEnumNetworkEvents;
  1701.          external     winsocket name 'WSAEnumNetworkEvents';
  1702. function WSACreateEvent;
  1703.          external     winsocket name 'WSACreateEvent';
  1704. function WSAConnect;
  1705.          external     winsocket name 'WSAConnect';
  1706. function WSACloseEvent;
  1707.          external     winsocket name 'WSACloseEvent';
  1708. function WSAAccept;
  1709.          external     winsocket name 'WSAAccept';
  1710.  
  1711. function TransmitFile;
  1712.          external     winsocket name 'TransmitFile';
  1713.  
  1714. end.
  1715.