📄 winsock2.pas
字号:
PF_NS = AF_NS;
PF_IPX = AF_IPX;
PF_ISO = AF_ISO;
PF_OSI = AF_OSI;
PF_ECMA = AF_ECMA;
PF_DATAKIT = AF_DATAKIT;
PF_CCITT = AF_CCITT;
PF_SNA = AF_SNA;
PF_DECnet = AF_DECnet;
PF_DLI = AF_DLI;
PF_LAT = AF_LAT;
PF_HYLINK = AF_HYLINK;
PF_APPLETALK = AF_APPLETALK;
PF_VOICEVIEW = AF_VOICEVIEW;
PF_FIREFOX = AF_FIREFOX;
PF_UNKNOWN1 = AF_UNKNOWN1;
PF_BAN = AF_BAN;
PF_ATM = AF_ATM;
PF_INET6 = AF_INET6;
PF_MAX = AF_MAX;
type
SunB = packed record
s_b1, s_b2, s_b3, s_b4: u_char;
end;
SunW = packed record
s_w1, s_w2: u_short;
end;
TInAddr = packed record
case integer of
0: (S_un_b: SunB);
1: (S_un_w: SunW);
2: (S_addr: u_long);
end;
PInAddr = ^TInAddr;
// Structure used by kernel to store most addresses.
TSockAddrIn = packed record
case Integer of
0: (sin_family: u_short;
sin_port: u_short;
sin_addr: TInAddr;
sin_zero: array[0..7] of Char);
1: (sa_family: u_short;
sa_data: array[0..13] of Char)
end;
PSockAddrIn = ^TSockAddrIn;
TSockAddr = TSockAddrIn;
PSockAddr = ^TSockAddr;
SOCKADDR = TSockAddr;
SOCKADDR_IN = TSockAddrIn;
// Structure used by kernel to pass protocol information in raw sockets.
PSockProto = ^TSockProto;
TSockProto = packed record
sp_family: u_short;
sp_protocol: u_short;
end;
// Structure used for manipulating linger option.
PLinger = ^TLinger;
TLinger = packed record
l_onoff: u_short;
l_linger: u_short;
end;
const
INADDR_ANY = $00000000;
INADDR_LOOPBACK = $7F000001;
INADDR_BROADCAST = $FFFFFFFF;
INADDR_NONE = $FFFFFFFF;
ADDR_ANY = INADDR_ANY;
SOL_SOCKET = $FFFF; // options for socket level
MSG_OOB = $1; // process out-of-band data
MSG_PEEK = $2; // peek at incoming message
MSG_DONTROUTE = $4; // send without using routing tables
MSG_PARTIAL = $8000; // partial send or recv for message xport
// WinSock 2 extension -- new flags for WSASend(), WSASendTo(), WSARecv() and WSARecvFrom()
MSG_INTERRUPT = $10; // send/recv in the interrupt context
MSG_MAXIOVLEN = 16;
// Define constant based on rfc883, used by gethostbyxxxx() calls.
MAXGETHOSTSTRUCT = 1024;
// Maximum queue length specifiable by listen.
SOMAXCONN = $7FFFFFFF;
// WinSock 2 extension -- bit values and indices for FD_XXX network events
FD_READ_BIT = 0;
FD_WRITE_BIT = 1;
FD_OOB_BIT = 2;
FD_ACCEPT_BIT = 3;
FD_CONNECT_BIT = 4;
FD_CLOSE_BIT = 5;
FD_QOS_BIT = 6;
FD_GROUP_QOS_BIT = 7;
FD_MAX_EVENTS = 8;
FD_READ = (1 shl FD_READ_BIT);
FD_WRITE = (1 shl FD_WRITE_BIT);
FD_OOB = (1 shl FD_OOB_BIT);
FD_ACCEPT = (1 shl FD_ACCEPT_BIT);
FD_CONNECT = (1 shl FD_CONNECT_BIT);
FD_CLOSE = (1 shl FD_CLOSE_BIT);
FD_QOS = (1 shl FD_QOS_BIT);
FD_GROUP_QOS = (1 shl FD_GROUP_QOS_BIT);
FD_ALL_EVENTS = (1 shl FD_MAX_EVENTS) - 1;
// 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;
WSAEINVALIDPROCTABLE = 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;
// Define QOS related error return codes
WSA_QOS_RECEIVERS = WSABASEERR + 1005; // at least one Reserve has arrived
WSA_QOS_SENDERS = WSABASEERR + 1006; // at least one Path has arrived
WSA_QOS_NO_SENDERS = WSABASEERR + 1007; // there are no senders
WSA_QOS_NO_RECEIVERS = WSABASEERR + 1008; // there are no receivers
WSA_QOS_REQUEST_CONFIRMED = WSABASEERR + 1009; // Reserve has been confirmed
WSA_QOS_ADMISSION_FAILURE = WSABASEERR + 1010;
// error due to lack of resources
WSA_QOS_POLICY_FAILURE = WSABASEERR + 1011;
// rejected for administrative reasons - bad credentials
WSA_QOS_BAD_STYLE = WSABASEERR + 1012; // unknown or conflicting style
WSA_QOS_BAD_OBJECT = WSABASEERR + 1013;
// problem with some part of the filterspec or providerspecific buffer in general
WSA_QOS_TRAFFIC_CTRL_ERROR = WSABASEERR + 1014;
// problem with some part of the flowspec
WSA_QOS_GENERIC_ERROR = WSABASEERR + 1015; // general error
WSA_QOS_ESERVICETYPE = WSABASEERR + 1016; // invalid service type in flowspec
WSA_QOS_EFLOWSPEC = WSABASEERR + 1017; // invalid flowspec
WSA_QOS_EPROVSPECBUF = WSABASEERR + 1018; // invalid provider specific buffer
WSA_QOS_EFILTERSTYLE = WSABASEERR + 1019; // invalid filter style
WSA_QOS_EFILTERTYPE = WSABASEERR + 1020; // invalid filter type
WSA_QOS_EFILTERCOUNT = WSABASEERR + 1021; // incorrect number of filters
WSA_QOS_EOBJLENGTH = WSABASEERR + 1022; // invalid object length
WSA_QOS_EFLOWCOUNT = WSABASEERR + 1023; // incorrect number of flows
WSA_QOS_EUNKOWNPSOBJ = WSABASEERR + 1024;
// unknown object in provider specific buffer
WSA_QOS_EPOLICYOBJ = WSABASEERR + 1025;
// invalid policy object in provider specific buffer
WSA_QOS_EFLOWDESC = WSABASEERR + 1026; // invalid flow descriptor in the list
WSA_QOS_EPSFLOWSPEC = WSABASEERR + 1027;
// inconsistent flow spec in provider specific buffer
WSA_QOS_EPSFILTERSPEC = WSABASEERR + 1028;
// invalid filter spec in provider specific buffer
WSA_QOS_ESDMODEOBJ = WSABASEERR + 1029;
// invalid shape discard mode object in provider specific buffer
WSA_QOS_ESHAPERATEOBJ = WSABASEERR + 1030;
// invalid shaping rate object in provider specific buffer
WSA_QOS_RESERVED_PETYPE = WSABASEERR + 1031;
// reserved policy element in provider specific buffer
{ WinSock 2 extension -- new error codes and type definition }
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 = $FFFFFFFF;
WSA_WAIT_EVENT_0 = WAIT_OBJECT_0;
WSA_WAIT_IO_COMPLETION = WAIT_IO_COMPLETION;
WSA_WAIT_TIMEOUT = WAIT_TIMEOUT;
WSA_INFINITE = INFINITE;
{ 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;
WSADESCRIPTION_LEN = 256;
WSASYS_STATUS_LEN = 128;
type
PWSAData = ^TWSAData;
TWSAData = packed record
wVersion: Word;
wHighVersion: Word;
szDescription: array[0..WSADESCRIPTION_LEN] of Char;
szSystemStatus: array[0..WSASYS_STATUS_LEN] of Char;
iMaxSockets: Word;
iMaxUdpDg: Word;
lpVendorInfo: PChar;
end;
{ WSAOVERLAPPED = Record
Internal: LongInt;
InternalHigh: LongInt;
Offset: LongInt;
OffsetHigh: LongInt;
hEvent: WSAEVENT;
end;}
WSAOVERLAPPED = TOverlapped;
TWSAOverlapped = WSAOverlapped;
PWSAOverlapped = ^WSAOverlapped;
LPWSAOVERLAPPED = PWSAOverlapped;
{ WinSock 2 extension -- WSABUF and QOS struct, include qos.h }
{ to pull in FLOWSPEC and related definitions }
WSABUF = packed record
len: U_LONG; { the length of the buffer }
buf: PChar; { the pointer to the buffer }
end {WSABUF};
PWSABUF = ^WSABUF;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -