📄 winsock2.pas
字号:
WSARecvFrom() }
MSG_INTERRUPT = $10; {send/recv in the interrupt context}
{ Define constant based on rfc883, used by gethostbyxxxx() calls. }
MAXGETHOSTSTRUCT = 1024;
{ Define flags to be used with the WSAAsyncSelect() call. }
FD_READ = $01;
FD_WRITE = $02;
FD_OOB = $04;
FD_ACCEPT = $08;
FD_CONNECT = $10;
FD_CLOSE = $20;
FD_QOS = $40;
FD_GROUP_QOS = $80;
FD_MAX_EVENTS = 8;
FD_ALL_EVENTS = $100; { AHS - trudno powiedzie? ile powinno by?}
{ All Windows Sockets error constants are biased by WSABASEERR from the "normal" }
WSABASEERR = 10000;
{ Windows Sockets definitions of regular Microsoft C error constants }
WSAEINTR = (WSABASEERR+4);
WSAEBADF = (WSABASEERR+9);
WSAEACCES = (WSABASEERR+13);
WSAEFAULT = (WSABASEERR+14);
WSAEINVAL = (WSABASEERR+22);
WSAEMFILE = (WSABASEERR+24);
{ Windows Sockets definitions of regular Berkeley error constants }
WSAEWOULDBLOCK = (WSABASEERR+35);
WSAEINPROGRESS = (WSABASEERR+36);
WSAEALREADY = (WSABASEERR+37);
WSAENOTSOCK = (WSABASEERR+38);
WSAEDESTADDRREQ = (WSABASEERR+39);
WSAEMSGSIZE = (WSABASEERR+40);
WSAEPROTOTYPE = (WSABASEERR+41);
WSAENOPROTOOPT = (WSABASEERR+42);
WSAEPROTONOSUPPORT = (WSABASEERR+43);
WSAESOCKTNOSUPPORT = (WSABASEERR+44);
WSAEOPNOTSUPP = (WSABASEERR+45);
WSAEPFNOSUPPORT = (WSABASEERR+46);
WSAEAFNOSUPPORT = (WSABASEERR+47);
WSAEADDRINUSE = (WSABASEERR+48);
WSAEADDRNOTAVAIL = (WSABASEERR+49);
WSAENETDOWN = (WSABASEERR+50);
WSAENETUNREACH = (WSABASEERR+51);
WSAENETRESET = (WSABASEERR+52);
WSAECONNABORTED = (WSABASEERR+53);
WSAECONNRESET = (WSABASEERR+54);
WSAENOBUFS = (WSABASEERR+55);
WSAEISCONN = (WSABASEERR+56);
WSAENOTCONN = (WSABASEERR+57);
WSAESHUTDOWN = (WSABASEERR+58);
WSAETOOMANYREFS = (WSABASEERR+59);
WSAETIMEDOUT = (WSABASEERR+60);
WSAECONNREFUSED = (WSABASEERR+61);
WSAELOOP = (WSABASEERR+62);
WSAENAMETOOLONG = (WSABASEERR+63);
WSAEHOSTDOWN = (WSABASEERR+64);
WSAEHOSTUNREACH = (WSABASEERR+65);
WSAENOTEMPTY = (WSABASEERR+66);
WSAEPROCLIM = (WSABASEERR+67);
WSAEUSERS = (WSABASEERR+68);
WSAEDQUOT = (WSABASEERR+69);
WSAESTALE = (WSABASEERR+70);
WSAEREMOTE = (WSABASEERR+71);
{ Extended Windows Sockets error constant definitions }
WSASYSNOTREADY = (WSABASEERR+91);
WSAVERNOTSUPPORTED = (WSABASEERR+92);
WSANOTINITIALISED = (WSABASEERR+93);
WSAEDISCON = (WSABASEERR+101);
WSAENOMORE = (WSABASEERR+102);
WSAECANCELLED = (WSABASEERR+103);
WSAEEINVALIDPROCTABLE = (WSABASEERR+104);
WSAEINVALIDPROVIDER = (WSABASEERR+105);
WSAEPROVIDERFAILEDINIT = (WSABASEERR+106);
WSASYSCALLFAILURE = (WSABASEERR+107);
WSASERVICE_NOT_FOUND = (WSABASEERR+108);
WSATYPE_NOT_FOUND = (WSABASEERR+109);
WSA_E_NO_MORE = (WSABASEERR+110);
WSA_E_CANCELLED = (WSABASEERR+111);
WSAEREFUSED = (WSABASEERR+112);
{ Error return codes from gethostbyname() and gethostbyaddr()
(when using the resolver). Note that these errors are
retrieved via WSAGetLastError() and must therefore follow
the rules for avoiding clashes with error numbers from
specific implementations or language run-time systems.
For this reason the codes are based at WSABASEERR+1001.
Note also that [WSA]NO_ADDRESS is defined only for
compatibility purposes. }
{ Authoritative Answer: Host not found }
WSAHOST_NOT_FOUND = (WSABASEERR+1001);
HOST_NOT_FOUND = WSAHOST_NOT_FOUND;
{ Non-Authoritative: Host not found, or SERVERFAIL }
WSATRY_AGAIN = (WSABASEERR+1002);
TRY_AGAIN = WSATRY_AGAIN;
{ Non recoverable errors, FORMERR, REFUSED, NOTIMP }
WSANO_RECOVERY = (WSABASEERR+1003);
NO_RECOVERY = WSANO_RECOVERY;
{ Valid name, no data record of requested type }
WSANO_DATA = (WSABASEERR+1004);
NO_DATA = WSANO_DATA;
{ no address, look for MX record }
WSANO_ADDRESS = WSANO_DATA;
NO_ADDRESS = WSANO_ADDRESS;
{ Windows Sockets errors redefined as regular Berkeley error constants.
These are commented out in Windows NT to avoid conflicts with errno.h.
Use the WSA constants instead. }
EWOULDBLOCK = WSAEWOULDBLOCK;
EINPROGRESS = WSAEINPROGRESS;
EALREADY = WSAEALREADY;
ENOTSOCK = WSAENOTSOCK;
EDESTADDRREQ = WSAEDESTADDRREQ;
EMSGSIZE = WSAEMSGSIZE;
EPROTOTYPE = WSAEPROTOTYPE;
ENOPROTOOPT = WSAENOPROTOOPT;
EPROTONOSUPPORT = WSAEPROTONOSUPPORT;
ESOCKTNOSUPPORT = WSAESOCKTNOSUPPORT;
EOPNOTSUPP = WSAEOPNOTSUPP;
EPFNOSUPPORT = WSAEPFNOSUPPORT;
EAFNOSUPPORT = WSAEAFNOSUPPORT;
EADDRINUSE = WSAEADDRINUSE;
EADDRNOTAVAIL = WSAEADDRNOTAVAIL;
ENETDOWN = WSAENETDOWN;
ENETUNREACH = WSAENETUNREACH;
ENETRESET = WSAENETRESET;
ECONNABORTED = WSAECONNABORTED;
ECONNRESET = WSAECONNRESET;
ENOBUFS = WSAENOBUFS;
EISCONN = WSAEISCONN;
ENOTCONN = WSAENOTCONN;
ESHUTDOWN = WSAESHUTDOWN;
ETOOMANYREFS = WSAETOOMANYREFS;
ETIMEDOUT = WSAETIMEDOUT;
ECONNREFUSED = WSAECONNREFUSED;
ELOOP = WSAELOOP;
ENAMETOOLONG = WSAENAMETOOLONG;
EHOSTDOWN = WSAEHOSTDOWN;
EHOSTUNREACH = WSAEHOSTUNREACH;
ENOTEMPTY = WSAENOTEMPTY;
EPROCLIM = WSAEPROCLIM;
EUSERS = WSAEUSERS;
EDQUOT = WSAEDQUOT;
ESTALE = WSAESTALE;
EREMOTE = WSAEREMOTE;
{ AHS }
{ WinSock 2 extension -- new error codes and type definition }
type
WSAEVENT = THANDLE;
LPHANDLE = PHANDLE;
LPWSAEVENT = LPHANDLE;
WSAOVERLAPPED = TOVERLAPPED;
LPWSAOVERLAPPED = POverlapped;
const
WSA_IO_PENDING = ERROR_IO_PENDING;
WSA_IO_INCOMPLETE = ERROR_IO_INCOMPLETE;
WSA_INVALID_HANDLE = ERROR_INVALID_HANDLE;
WSA_INVALID_PARAMETER = ERROR_INVALID_PARAMETER;
WSA_NOT_ENOUGH_MEMORY = ERROR_NOT_ENOUGH_MEMORY;
WSA_OPERATION_ABORTED = ERROR_OPERATION_ABORTED;
WSA_INVALID_EVENT = WSAEVENT(NiL);
WSA_MAXIMUM_WAIT_EVENTS = MAXIMUM_WAIT_OBJECTS;
WSA_WAIT_FAILED = DWORD($FFFFFFFF); { ahs }
WSA_WAIT_EVENT_0 = WAIT_OBJECT_0;
WSA_WAIT_IO_COMPLETION = WAIT_IO_COMPLETION;
WSA_WAIT_TIMEOUT = WAIT_TIMEOUT;
WSA_INFINITE = INFINITE;
{ WinSock 2 extension -- WSABUF and QOS struct }
type
PWSABUF = ^TWSABUF;
TWSABUF = packed record
len : u_long; { the length of the buffer }
buf : Pointer; //PChar; { the pointer to the buffer }
end;
GUARANTEE = (
BestEffortService,
ControlledLoadService,
PredictiveService,
GuaranteedDelayService,
GuaranteedService
);
PFlowspec = ^TFlowspec;
TFlowspec = packed record
TokenRate : LongInt; { In Bytes/sec }
TokenBucketSize : LongInt; { In Bytes }
PeakBandwidth : LongInt; { In Bytes/sec }
Latency : LongInt; { In microseconds }
DelayVariation : LongInt; { In microseconds }
LevelOfGuarantee : Guarantee; { Guaranteed, Predictive }
{ or Best Effort }
CostOfCall : LongInt; { Reserved for future use, }
{ must be set to 0 now }
NetworkAvailability : LongInt; { read-only: }
{ 1 if accessible, }
{ 0 if not }
end;
PQOS = ^TQualityOfService;
TQualityOfService = packed record
SendingFlowspec :TFlowspec; { the flow spec for data sending }
ReceivingFlowspec :TFlowspec; { the flow spec for data receiving }
ProviderSpecific :TWSABuf; { additional provider specific stuff }
end;
const
{ WinSock 2 extension -- manifest constants for return values of the
condition function}
CF_ACCEPT = $0000;
CF_REJECT = $0001;
CF_DEFER = $0002;
{WinSock 2 extension -- manifest constants for shutdown() }
SD_RECEIVE = $00;
SD_SEND = $01;
SD_BOTH = $02;
{ WinSock 2 extension -- data type and manifest constants for socket groups }
type
TGroup = u_int;
PGroup = ^TGroup;
const
SG_UNCONSTRAINED_GROUP = $01;
SG_CONSTRAINED_GROUP = $02;
{ WinSock 2 extension -- data type for WSAEnumNetworkEvents() }
type
PWSANETWORKEVENTS = ^TWSANETWORKEVENTS;
TWSANETWORKEVENTS = packed record
lNetworkEvents :u_long;
iErrorCode : array [0..FD_MAX_EVENTS-1] of u_int;
end;
{WinSock 2 extension -- WSAPROTOCOL_INFO structure and associated
manifest constants}
PGUID = ^TGUID;
TGUID = packed record
Data1 :u_long;
Data2 :u_short;
Data3 :u_short;
Data4 : array [0..8-1] of u_char;
end;
const
MAX_PROTOCOL_CHAIN = 7;
BASE_PROTOCOL = 1;
LAYERED_PROTOCOL = 0;
type
PWSAPROTOCOLCHAIN = ^TWSAPROTOCOLCHAIN;
TWSAPROTOCOLCHAIN = packed record
ChainLen : Integer; { the length of the chain, }
{ length = 0 means layered protocol, }
{ length = 1 means base protocol, }
{ length > 1 means protocol chain }
ChainEntries : array[0..MAX_PROTOCOL_CHAIN-1] of DWORD; { a list of dwCatalogEntryIds }
end;
const
WSAPROTOCOL_LEN = 255;
type
PWSAPROTOCOL_INFOA = ^TWSAPROTOCOL_INFOA;
TWSAPROTOCOL_INFOA = packed record
dwServiceFlags1 : DWORD;
dwServiceFlags2 : DWORD;
dwServiceFlags3 : DWORD;
dwServiceFlags4 : DWORD;
dwProviderFlags : DWORD;
ProviderId : TGUID;
dwCatalogEntryId : DWORD;
ProtocolChain : TWSAPROTOCOLCHAIN;
iVersion : u_int;
iAddressFamily : u_int;
iMaxSockAddr : u_int;
iMinSockAddr : u_int;
iSocketType : u_int;
iProtocol : u_int;
iProtocolMaxOffset : u_int;
iNetworkByteOrder : u_int;
iSecurityScheme : u_int;
dwMessageSize : DWORD;
dwProviderReserved : DWORD;
szProtocol : array [0..WSAPROTOCOL_LEN+1-1] of u_char;
end;
PWSAPROTOCOL_INFOW = ^TWSAPROTOCOL_INFOW;
TWSAPROTOCOL_INFOW = packed record
dwServiceFlags1 : DWORD;
dwServiceFlags2 : DWORD;
dwServiceFlags3 : DWORD;
dwServiceFlags4 : DWORD;
dwProviderFlags : DWORD;
ProviderId : TGUID;
dwCatalogEntryId : DWORD;
ProtocolChain : TWSAPROTOCOLCHAIN;
iVersion : u_int;
iAddressFamily : u_int;
iMaxSockAddr : u_int;
iMinSockAddr : u_int;
iSocketType : u_int;
iProtocol : u_int;
iProtocolMaxOffset : u_int;
iNetworkByteOrder : u_int;
iSecurityScheme : u_int;
dwMessageSize : DWORD;
dwProviderReserved : DWORD;
szProtocol : array [0..WSAPROTOCOL_LEN+1-1] of WCHAR;
end;
{$ifdef UNICODE}
TWSAPROTOCOL_INFO = TWSAPROTOCOL_INFOW ;
PWSAPROTOCOL_INFO = PWSAPROTOCOL_INFOW ;
{$else}
TWSAPROTOCOL_INFO = TWSAPROTOCOL_INFOA ;
PWSAPROTOCOL_INFO = PWSAPROTOCOL_INFOA ;
{$endif UNICODE}
const
{ Flag bit definitions for dwProviderFlags }
PFL_MULTIPLE_PROTO_ENTRIES =$00000001;
PFL_RECOMMENDED_PROTO_ENTRY =$00000002;
PFL_HIDDEN =$00000004;
PFL_MATCHES_PROTOCOL_ZERO =$00000008;
{ Flag bit definitions for dwServiceFlags1 }
XP1_CONNECTIONLESS =$00000001;
XP1_GUARANTEED_DELIVERY =$00000002;
XP1_GUARANTEED_ORDER =$00000004;
XP1_MESSAGE_ORIENTED =$00000008;
XP1_PSEUDO_STREAM =$00000010;
XP1_GRACEFUL_CLOSE =$00000020;
XP1_EXPEDITED_DATA =$00000040;
XP1_CONNECT_DATA =$00000080;
XP1_DISCONNECT_DATA =$00000100;
XP1_SUPPORT_BROADCAST =$00000200;
XP1_SUPPORT_MULTIPOINT =$00000400;
XP1_MULTIPOINT_CONTROL_PLANE =$00000800;
XP1_MULTIPOINT_DATA_PLANE =$00001000;
XP1_QOS_SUPPORTED =$00002000;
XP1_INTERRUPT =$00004000;
XP1_UNI_SEND =$00008000;
XP1_UNI_RECV =$00010000;
XP1_IFS_HANDLES =$00020000;
XP1_PARTIAL_MESSAGE =$00040000;
BIGENDIAN =$0000;
LITTLEENDIAN =$0001;
SECURITY_PROTOCOL_NONE =$0000;
{ WinSock 2 extension -- manifest constants for WSAJoinLeaf() }
JL_SENDER_ONLY =$01;
JL_RECEIVER_ONLY =$02;
JL_BOTH =$04;
{ WinSock 2 extension -- manifest constants for WSASocket() }
WSA_FLAG_OVERLAPPED =$01;
WSA_FLAG_MULTIPOINT_C_ROOT =$02;
WSA_FLAG_MULTIPOINT_C_LEAF =$04;
WSA_FLAG_MULTIPOINT_D_ROOT =$08;
WSA_FLAG_MULTIPOINT_D_LEAF =$10;
{ WinSock 2 extension -- manifest constants for WSAIoctl() }
IOC_UNIX =$00000000;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -