📄 ssdotnet.~pas
字号:
{==============================================================================|
| Project : Ararat Synapse | 001.000.002 |
|==============================================================================|
| Content: Socket Independent Platform Layer - .NET definition include |
|==============================================================================|
| Copyright (c)2004, Lukas Gebauer |
| All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions are met: |
| |
| Redistributions of source code must retain the above copyright notice, this |
| list of conditions and the following disclaimer. |
| |
| Redistributions in binary form must reproduce the above copyright notice, |
| this list of conditions and the following disclaimer in the documentation |
| and/or other materials provided with the distribution. |
| |
| Neither the name of Lukas Gebauer nor the names of its contributors may |
| be used to endorse or promote products derived from this software without |
| specific prior written permission. |
| |
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR |
| ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
| DAMAGE. |
|==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c)2004. |
| All Rights Reserved. |
|==============================================================================|
| Contributor(s): |
|==============================================================================|
| History: see HISTORY.HTM from distribution package |
| (Found at URL: http://www.ararat.cz/synapse/) |
|==============================================================================}
{:@exclude}
{$IFDEF CIL}
interface
uses
SyncObjs, SysUtils,
System.Net,
System.Net.Sockets;
const
DLLStackName = '';
WinsockLevel = $0202;
function InitSocketInterface(stack: string): Boolean;
function DestroySocketInterface: Boolean;
type
u_char = Char;
u_short = Word;
u_int = Integer;
u_long = Longint;
pu_long = ^u_long;
pu_short = ^u_short;
PSockAddr = IPEndPoint;
DWORD = integer;
ULong = cardinal;
TMemory = Array of byte;
TLinger = LingerOption;
TSocket = socket;
const
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;
SunB6 = packed record
s_b1, s_b2, s_b3, s_b4,
s_b5, s_b6, s_b7, s_b8,
s_b9, s_b10, s_b11, s_b12,
s_b13, s_b14, s_b15, s_b16: u_char;
end;
S6_Bytes = SunB6;
S6_Addr = SunB6;
TInAddr6 = packed record
S_un_b: SunB6;
end;
TSockAddrIn6 = packed record
sin6_family: u_short; // AF_INET6
sin6_port: u_short; // Transport level port number
sin6_flowinfo: u_long; // IPv6 flow information
sin6_addr: TInAddr6; // IPv6 address
sin6_scope_id: u_long; // Scope Id: IF number for link-local
// SITE id for site-local
end;
const
MSG_NOSIGNAL = 0;
INVALID_SOCKET = nil;
AF_INET = AddressFamily.InterNetwork;
AF_INET6 = AddressFamily.InterNetworkV6;
SOCKET_ERROR = integer(-1);
FIONREAD = integer($4004667f);
FIONBIO = integer($8004667e);
FIOASYNC = integer($8004667d);
SOMAXCONN = integer($7fffffff);
IPPROTO_IP = ProtocolType.IP;
IPPROTO_ICMP = ProtocolType.Icmp;
IPPROTO_IGMP = ProtocolType.Igmp;
IPPROTO_TCP = ProtocolType.Tcp;
IPPROTO_UDP = ProtocolType.Udp;
IPPROTO_RAW = ProtocolType.Raw;
IPPROTO_IPV6 = ProtocolType.IPV6;
//
IPPROTO_ICMPV6 = ProtocolType.Icmp; //??
SOCK_STREAM = SocketType.Stream;
SOCK_DGRAM = SocketType.Dgram;
SOCK_RAW = SocketType.Raw;
SOCK_RDM = SocketType.Rdm;
SOCK_SEQPACKET = SocketType.Seqpacket;
SOL_SOCKET = SocketOptionLevel.Socket;
SOL_IP = SocketOptionLevel.Ip;
IP_OPTIONS = SocketOptionName.IPOptions;
IP_HDRINCL = SocketOptionName.HeaderIncluded;
IP_TOS = SocketOptionName.TypeOfService; { set/get IP Type Of Service }
IP_TTL = SocketOptionName.IpTimeToLive; { set/get IP Time To Live }
IP_MULTICAST_IF = SocketOptionName.MulticastInterface; { set/get IP multicast interface }
IP_MULTICAST_TTL = SocketOptionName.MulticastTimeToLive; { set/get IP multicast timetolive }
IP_MULTICAST_LOOP = SocketOptionName.MulticastLoopback; { set/get IP multicast loopback }
IP_ADD_MEMBERSHIP = SocketOptionName.AddMembership; { add an IP group membership }
IP_DROP_MEMBERSHIP = SocketOptionName.DropMembership; { drop an IP group membership }
IP_DONTFRAGMENT = SocketOptionName.DontFragment; { set/get IP Don't Fragment flag }
IPV6_UNICAST_HOPS = 8; // TTL
IPV6_MULTICAST_IF = 9; // set/get IP multicast i/f
IPV6_MULTICAST_HOPS = 10; // set/get IP multicast ttl
IPV6_MULTICAST_LOOP = 11; // set/get IP multicast loopback
IPV6_JOIN_GROUP = 12; // add an IP group membership
IPV6_LEAVE_GROUP = 13; // drop an IP group membership
SO_DEBUG = SocketOptionName.Debug; { turn on debugging info recording }
SO_ACCEPTCONN = SocketOptionName.AcceptConnection; { socket has had listen() }
SO_REUSEADDR = SocketOptionName.ReuseAddress; { allow local address reuse }
SO_KEEPALIVE = SocketOptionName.KeepAlive; { keep connections alive }
SO_DONTROUTE = SocketOptionName.DontRoute; { just use interface addresses }
SO_BROADCAST = SocketOptionName.Broadcast; { permit sending of broadcast msgs }
SO_USELOOPBACK = SocketOptionName.UseLoopback; { bypass hardware when possible }
SO_LINGER = SocketOptionName.Linger; { linger on close if data present }
SO_OOBINLINE = SocketOptionName.OutOfBandInline; { leave received OOB data in line }
SO_DONTLINGER = SocketOptionName.DontLinger;
{ Additional options. }
SO_SNDBUF = SocketOptionName.SendBuffer; { send buffer size }
SO_RCVBUF = SocketOptionName.ReceiveBuffer; { receive buffer size }
SO_SNDLOWAT = SocketOptionName.SendLowWater; { send low-water mark }
SO_RCVLOWAT = SocketOptionName.ReceiveLowWater; { receive low-water mark }
SO_SNDTIMEO = SocketOptionName.SendTimeout; { send timeout }
SO_RCVTIMEO = SocketOptionName.ReceiveTimeout; { receive timeout }
SO_ERROR = SocketOptionName.Error; { get error status and clear }
SO_TYPE = SocketOptionName.Type; { get socket type }
{ WinSock 2 extension -- new options }
// SO_GROUP_ID = $2001; { ID of a socket group}
// SO_GROUP_PRIORITY = $2002; { the relative priority within a group}
// SO_MAX_MSG_SIZE = $2003; { maximum message size }
// SO_PROTOCOL_INFOA = $2004; { WSAPROTOCOL_INFOA structure }
// SO_PROTOCOL_INFOW = $2005; { WSAPROTOCOL_INFOW structure }
// SO_PROTOCOL_INFO = SO_PROTOCOL_INFOA;
// PVD_CONFIG = $3001; {configuration info for service provider }
{ Option for opening sockets for synchronous access. }
// SO_OPENTYPE = $7008;
// SO_SYNCHRONOUS_ALERT = $10;
// SO_SYNCHRONOUS_NONALERT = $20;
{ Other NT-specific options. }
// SO_MAXDG = $7009;
// SO_MAXPATHDG = $700A;
// SO_UPDATE_ACCEPT_CONTEXT = $700B;
// SO_CONNECT_TIME = $700C;
{ 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;
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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -