📄 adwutil.pas
字号:
(***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TurboPower Async Professional
*
* The Initial Developer of the Original Code is
* TurboPower Software
*
* Portions created by the Initial Developer are Copyright (C) 1991-2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** *)
{*********************************************************}
{* ADWUTIL.PAS 4.06 *}
{*********************************************************}
{* Winsock DLL interface and utility methods *}
{*********************************************************}
{Global defines potentially affecting this unit}
{$I AWDEFINE.INC}
{Options required for this unit}
{$G+,X+,F+}
{$C MOVEABLE,DEMANDLOAD,DISCARDABLE}
unit AdWUtil;
{ -Basic Winsock interface unit }
interface
uses
Classes,
WinTypes,
WinProcs,
SysUtils,
OOMisc;
type
TSocket = Integer;
{$IFNDEF Win32}
AnsiChar = Char;
PAnsiChar = ^Char;
{$ENDIF}
const
{ Version of Winsock that we support }
Sock_Version = $0101;
Fd_Setsize = 64;
IocParm_Mask = $7F;
Ioc_Void = $20000000;
Ioc_Out = $40000000;
Ioc_In = $80000000;
Ioc_InOut = (Ioc_In or Ioc_Out);
{ Protocols }
IpProto_Ip = 0; { Dummy for IP }
IpProto_Icmp = 1; { Control message protocol }
IpProto_Igmp = 2; { Group management protocol }
IpProto_Ggp = 3; { Gateway^2 (deprecated) }
IpProto_Tcp = 6; { Tcp }
IpProto_Pup = 12; { Pup }
IpProto_Udp = 17; { User datagram protocol }
IpProto_Idp = 22; { Xns idp }
IpProto_Nd = 77; { UNOFFICIAL net disk proto }
IpProto_Raw = 255; { Raw IP packet }
IpProto_Max = 256;
{ Port/socket numbers: network standard functions}
IpPort_Echo = 7;
IpPort_Discard = 9;
IpPort_SyStat = 11;
IpPort_Daytime = 13;
IpPort_NetStat = 15;
IpPort_Ftp = 21;
IpPort_Telnet = 23;
IpPort_Smtp = 25;
IpPort_TimeServer = 37;
IpPort_NameServer = 42;
IpPort_WhoIs = 43;
IpPort_Mtp = 57;
{ Port/socket numbers: host specific functions }
IpPort_Tftp = 69;
IpPort_Rje = 77;
IpPort_Finger = 79;
IpPort_TtyLink = 87;
IpPort_SupDup = 95;
{ Unix TCP sockets }
IpPort_ExecServer = 512;
IpPort_LoginServer = 513;
IpPort_CmdServer = 514;
IpPort_EfsServer = 520;
{ Unix UDP sockets }
IpPort_BiffUdp = 512;
IpPort_WhoServer = 513;
IpPort_RouteServer = 520;
{ Ports < IpPort_Reserved are reserved for privileged processes (e.g. root). }
IpPort_Reserved = 1024;
{ Link numbers }
ImpLink_Ip = 155;
ImpLink_LowExper = 156;
ImpLink_HighExper = 158;
{ Get # bytes to read }
FiOnRead = Ioc_Out or ((LongInt(SizeOf(LongInt)) and IocParm_Mask) shl 16) or
(LongInt(Byte('f')) shl 8) or 127;
{ Set/Clear non-blocking i/o }
FiOnBio = Ioc_In or((LongInt(SizeOf(LongInt)) and IocParm_Mask) shl 16) or
(LongInt(Byte('f')) shl 8) or 126;
{ Set/Clear async i/o }
FioAsync = Ioc_In or ((LongInt(SizeOf(LongInt)) and IocParm_Mask) shl 16) or
(LongInt(Byte('f')) shl 8) or 125;
InAddr_Any = $00000000;
InAddr_LoopBack = $7F000001;
InAddr_BroadCast = $FFFFFFFF;
InAddr_None = $FFFFFFFF;
wsaDescription_Len = 256;
wsaSys_Status_Len = 128;
{ Options for use with (get/set)sockopt at the IP level. }
Ip_Options = 1;
Ip_Multicast_If = 2; { set/get IP multicast interface }
Ip_Multicast_Ttl = 3; { set/get IP multicast timetolive }
Ip_Multicast_Loop = 4; { set/get IP multicast loopback }
Ip_Add_Membership = 5; { add an IP group membership }
Ip_Drop_Membership = 6; { drop an IP group membership }
Ip_Default_Multicast_Ttl = 1; { normally limit m'casts to 1 hop }
Ip_Default_Multicast_Loop = 1; { normally hear sends if a member }
Ip_Max_Memberships = 20; { per socket; must fit in one mbuf }
{ This is used instead of -1, since the TSocket type is unsigned.}
Invalid_Socket = TSocket(not(0));
Socket_Error = -1;
{ Types }
Sock_Stream = 1; { stream socket }
Sock_DGram = 2; { datagram socket }
Sock_Raw = 3; { raw-protocol interface }
Sock_Rdm = 4; { reliably-delivered message }
Sock_SeqPacket = 5; { sequenced packet stream }
{ Option flags per-socket. }
So_Debug = $0001; { turn on debugging info recording }
So_AcceptConn = $0002; { socket has had listen() }
So_ReuseAddr = $0004; { allow local address reuse }
So_KeepAlive = $0008; { keep connections alive }
So_DontRoute = $0010; { just use interface addresses }
So_Broadcast = $0020; { permit sending of broadcast msgs }
So_UseLoopback = $0040; { bypass hardware when possible }
So_Linger = $0080; { linger on close if data present }
So_OobInline = $0100; { leave received OOB data in line }
So_DontLinger = $FF7F;
SD_Receive = $0000;
SD_Send = $0001;
SD_Both = $0002;
{ Additional options. }
So_SndBuf = $1001; { send buffer size }
So_RcvBuf = $1002; { receive buffer size }
So_SndLoWat = $1003; { send low-water mark }
So_RcvLoWat = $1004; { receive low-water mark }
So_SndTimeO = $1005; { send timeout }
So_RcvTimeO = $1006; { receive timeout }
So_Error = $1007; { get error status and clear }
So_Type = $1008; { get socket type }
{ Options for connect and disconnect data and options. Used only by }
{ non-TCP/IP transports such as DecNet, Osi TP4, etc. }
So_ConnData = $7000;
So_ConnOpt = $7001;
So_DISCData = $7002;
So_DISCOpt = $7003;
So_ConnDataLen = $7004;
So_ConnOptLen = $7005;
So_DISCDataLen = $7006;
So_DISCOptLen = $7007;
{ 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;
{ TCP options. }
Tcp_NoDelay = $0001;
Tcp_BsdUrgent = $7000;
{ Address families. }
Af_Unspec = 0; { unspecified }
Af_Unix = 1; { local to host (pipes, portals) }
Af_Inet = 2; { internetwork: UDP, TCP, etc. }
Af_ImpLink = 3; { arpanet imp addresses }
Af_Pup = 4; { pup protocols: e.g. BSP }
Af_Chaos = 5; { mit Chaos protocols }
Af_Ipx = 6; { Ipx and SPX }
Af_Ns = 6; { XEROX Ns protocols }
Af_Iso = 7; { Iso protocols }
Af_Osi = Af_Iso; { Osi is Iso }
Af_Ecma = 8; { european computer manufacturers }
Af_DataKit = 9; { datakit protocols }
Af_CcItt = 10; { CcItt protocols, X.25 etc }
Af_Sna = 11; { IBM Sna }
Af_DecNet = 12; { DecNet }
Af_Dli = 13; { Direct data link interface }
Af_Lat = 14; { Lat }
Af_HyLink = 15; { NsC Hyperchannel }
Af_AppleTalk = 16; { AppleTalk }
Af_NetBios = 17; { NetBios-style addresses }
Af_VoiceView = 18; { VoiceView }
Af_Max = 19;
{ Protocol families, same as address families for now. }
Pf_Unspec = Af_Unspec;
Pf_Unix = Af_Unix;
Pf_Inet = Af_Inet;
Pf_ImpLink = Af_ImpLink;
Pf_Pup = Af_Pup;
Pf_Chaos = Af_Chaos;
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_Max = Af_Max;
{ Level number for (get/set)sockopt() to apply to socket itself. }
Sol_Socket = $FFFF; {options for socket level }
{ Maximum queue length specifiable by listen. }
SoMaxConn = 5;
Msg_Oob = $1; {process out-of-band data }
Msg_Peek = $2; {peek at incoming message }
Msg_DontRoute = $4; {send without using routing tables }
Msg_MaxIovLen = 16;
Msg_Partial = $8000; {partial send or recv for message xport }
{ 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;
{ moved wsa* error consts to OOMisc } {!!.04}
{ 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;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -