IdStack.pas
上传用户:xiangshu02
上传日期:2014-03-17
资源大小:5750k
文件大小:19k
源码类别:

视频捕捉/采集

开发平台:

Delphi

  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence                                   }
  4. { Team Coherence is Copyright 2002 by Quality Software Components      }
  5. {                                                                      }
  6. { For further information / comments, visit our WEB site at            }
  7. { http://www.TeamCoherence.com                                         }
  8. {**********************************************************************}
  9. {}
  10. { $Log:  10343: IdStack.pas 
  11. {
  12. {   Rev 1.2    2003.06.04 10:49:12 PM  czhower
  13. { Fixed bug which caused IsIP to fail on successive calls because of
  14. { unitialized values and therefore caused connect errors.
  15. }
  16. {
  17. {   Rev 1.1    4/20/03 1:49:26 PM  RLebeau
  18. { Added new methods: GetIPInfo(), GetIPType(), GetIPClass(), IPIsType(),
  19. { IPIsClass(), IsDottedIP(), and IsNumericIP().
  20. { Added EIdInvalidIPAddress exception class.
  21. }
  22. {
  23. {   Rev 1.0    2002.11.12 10:53:10 PM  czhower
  24. }
  25. unit IdStack;
  26. interface
  27. uses
  28.   Classes,
  29.   IdException,
  30.   IdStackConsts, IdGlobal;
  31. type
  32.   TIdServeFile = function(ASocket: TIdStackSocketHandle; AFileName: string): cardinal;
  33.   // Abstract IdStack class
  34.   TIdSunB = packed record
  35.     s_b1, s_b2, s_b3, s_b4: byte;
  36.   end;
  37.   TIdSunW = packed record
  38.     s_w1, s_w2: word;
  39.   end;
  40.   PIdInAddr = ^TIdInAddr;
  41.   TIdInAddr = record
  42.     case integer of
  43.       0: (S_un_b: TIdSunB);
  44.       1: (S_un_w: TIdSunW);
  45.       2: (S_addr: longword);
  46.   end;
  47.   TIdIPType = (Id_IPInvalid, Id_IPDotted, Id_IPNumeric);
  48.   PIdIPType = ^TIdIPType;
  49.   TIdIPClass = (Id_IPClassUnkn, Id_IPClassA, Id_IPClassB, Id_IPClassC, Id_IPClassD, Id_IPClassE);
  50.   PIdIPClass = ^TIdIPClass;
  51.   TIdSocketListClass = class of TIdSocketList;
  52.   TIdSocketList = class
  53.   protected
  54.     function GetItem(AIndex: Integer): TIdStackSocketHandle; virtual; abstract;
  55.   public
  56.     procedure Add(AHandle: TIdStackSocketHandle); virtual; abstract;
  57.     class function CreateSocketList: TIdSocketList;
  58.     procedure Remove(AHandle: TIdStackSocketHandle); virtual; abstract;
  59.     function  Count: Integer; virtual; abstract;
  60.     property  Items[AIndex: Integer]: TIdStackSocketHandle read GetItem; default;
  61.   End;//TIdSocketList
  62.   TIdStack = class
  63.   protected
  64.     FLastError: Integer;
  65.     FLocalAddress: string;
  66.     FLocalAddresses: TStrings;
  67.     //
  68.     procedure PopulateLocalAddresses; virtual; abstract;
  69.     function WSGetLocalAddress: string; virtual; abstract;
  70.     function WSGetLocalAddresses: TStrings; virtual; abstract;
  71.   public
  72.     function CheckForSocketError(const AResult: integer = Id_SOCKET_ERROR): boolean; overload;
  73.     function CheckForSocketError(const AResult: integer; const AIgnore: array of integer)
  74.      : boolean; overload;
  75.     constructor Create; reintroduce; virtual;
  76.     destructor Destroy; override;
  77.     class function CreateStack: TIdStack;
  78.     function CreateSocketHandle(const ASocketType: Integer;
  79.       const AProtocol: Integer = Id_IPPROTO_IP): TIdStackSocketHandle;
  80.     function GetIPInfo(const AIP: string; VB1: PByte = nil; VB2: PByte = nil;
  81.       VB3: PByte = nil; VB4: PByte = nil; VType: PIdIPType = nil; VClass: PIdIPClass = nil): Boolean;
  82.     function GetIPType(const AIP: string): TIdIPType;
  83.     function GetIPClass(const AIP: string): TIdIPClass;
  84.     function IsIP(const AIP: string): boolean;
  85.     function IPIsType(const AIP: string; const AType: TIdIPType): boolean; overload;
  86.     function IPIsType(const AIP: string; const ATypes: array of TIdIPType): boolean; overload;
  87.     function IPIsClass(const AIP: string; const AClass: TIdIPClass): boolean; overload;
  88.     function IPIsClass(const AIP: string; const AClasses: array of TIdIPClass): boolean; overload;
  89.     function IsDottedIP(const AIP: string): boolean;
  90.     function IsNumericIP(const AIP: string): boolean;
  91.     procedure RaiseSocketError(const AErr: integer);
  92.     function ResolveHost(const AHost: string): string;
  93.     // Resolves host passed in sHost. sHost may be an IP or a HostName.
  94.     // sIP returns string version of the IP
  95.     function WSAccept(ASocket: TIdStackSocketHandle; var VIP: string; var VPort: Integer)
  96.      : TIdStackSocketHandle; virtual; abstract;
  97.     function WSBind(ASocket: TIdStackSocketHandle; const AFamily: Integer;
  98.      const AIP: string; const APort: Integer): Integer; virtual; abstract;
  99.     function WSCloseSocket(ASocket: TIdStackSocketHandle): Integer; virtual; abstract;
  100.     function WSConnect(const ASocket: TIdStackSocketHandle; const AFamily: Integer;
  101.      const AIP: string; const APort: Integer): Integer; virtual; abstract;
  102.     function WSGetHostByName(const AHostName: string): string; virtual; abstract;
  103.     function WSGetHostName: string; virtual; abstract;
  104.     function WSGetHostByAddr(const AAddress: string): string; virtual; abstract;
  105.     function WSGetServByName(const AServiceName: string): Integer; virtual; abstract;
  106.     function WSGetServByPort(const APortNumber: Integer): TStrings; virtual; abstract;
  107.     function WSHToNs(AHostShort: Word): Word; virtual; abstract;
  108.     function WSListen(ASocket: TIdStackSocketHandle; ABackLog: Integer): Integer; virtual; abstract;
  109.     function WSNToHs(ANetShort: Word): Word; virtual; abstract;
  110.     function WSHToNL(AHostLong: LongWord): LongWord; virtual; abstract;
  111.     function WSNToHL(ANetLong: LongWord): LongWord; virtual; abstract;
  112.     function WSRecv(ASocket: TIdStackSocketHandle; var ABuffer; const ABufferLength, AFlags: Integer)
  113.      : Integer; virtual; abstract;
  114.     function WSRecvFrom(const ASocket: TIdStackSocketHandle; var ABuffer;
  115.      const ALength, AFlags: Integer; var VIP: string; var VPort: Integer): Integer; virtual;
  116.      abstract;
  117.     function WSSelect(ARead, AWrite, AErrors: TList; ATimeout: Integer): Integer; virtual; abstract;
  118.     function WSSend(ASocket: TIdStackSocketHandle; var ABuffer;
  119.      const ABufferLength, AFlags: Integer): Integer; virtual; abstract;
  120.     function WSSendTo(ASocket: TIdStackSocketHandle; var ABuffer;
  121.      const ABufferLength, AFlags: Integer; const AIP: string; const APort: integer): Integer;
  122.       virtual; abstract;
  123.     function WSSetSockOpt(ASocket: TIdStackSocketHandle; ALevel, AOptName: Integer; AOptVal: PChar;
  124.      AOptLen: Integer): Integer; virtual; abstract;
  125.     function WSSocket(AFamily, AStruct, AProtocol: Integer): TIdStackSocketHandle; virtual; abstract;
  126.     function WSShutdown(ASocket: TIdStackSocketHandle; AHow: Integer): Integer; virtual; abstract;
  127.     function WSTranslateSocketErrorMsg(const AErr: integer): string; virtual;
  128.     function WSGetLastError: Integer; virtual; abstract;
  129.     procedure WSGetPeerName(ASocket: TIdStackSocketHandle; var AFamily: Integer;
  130.      var AIP: string; var APort: Integer); virtual; abstract;
  131.     procedure WSGetSockName(ASocket: TIdStackSocketHandle; var AFamily: Integer;
  132.      var AIP: string; var APort: Integer); virtual; abstract;
  133.     function WSGetSockOpt(ASocket: TIdStackSocketHandle; Alevel, AOptname: Integer; AOptval: PChar; var AOptlen: Integer) : Integer; virtual; abstract;
  134.     function StringToTInAddr(AIP: string): TIdInAddr;
  135.     function TInAddrToString(var AInAddr): string; virtual; abstract;
  136.     procedure TranslateStringToTInAddr(AIP: string; var AInAddr); virtual; abstract;
  137.     //
  138.     property LastError: Integer read FLastError;
  139.     property LocalAddress: string read WSGetLocalAddress;
  140.     property LocalAddresses: TStrings read WSGetLocalAddresses;
  141.   end;
  142.   TIdStackClass = class of TIdStack;
  143.   EIdStackError = class (EIdException);
  144.   EIdStackInitializationFailed = class (EIdStackError);
  145.   EIdStackSetSizeExceeded = class (EIdStackError);
  146.   EIdInvalidIPAddress = class (EIdStackError);
  147. var
  148.   GStack: TIdStack = nil;
  149.   GStackClass: TIdStackClass = nil;
  150.   GServeFileProc: TIdServeFile = nil;
  151.   GSocketListClass: TIdSocketListClass;
  152. implementation
  153. uses
  154.   IdResourceStrings,
  155.   SysUtils;
  156. { TIdStack }
  157. function TIdStack.CheckForSocketError(const AResult: integer): boolean;
  158. begin
  159.   Result := CheckForSocketError(AResult, []);
  160. end;
  161. function TIdStack.CheckForSocketError(const AResult: integer;
  162.   const AIgnore: array of integer): boolean;
  163. var
  164.   i: integer;
  165. begin
  166.   Result := false;
  167.   if AResult = Id_SOCKET_ERROR then begin
  168.     FLastError := WSGetLastError;
  169.     for i := Low(AIgnore) to High(AIgnore) do begin
  170.       if LastError = AIgnore[i] then begin
  171.         Result := True;
  172.         exit;
  173.       end;
  174.     end;
  175.     RaiseSocketError(LastError);
  176.   end;
  177. end;
  178. function TIdStack.CreateSocketHandle(const ASocketType: Integer;
  179.   const AProtocol: Integer = Id_IPPROTO_IP): TIdStackSocketHandle;
  180. begin
  181.   result := WSSocket(Id_PF_INET, ASocketType, AProtocol);
  182.   if result = Id_INVALID_SOCKET then begin
  183.     raise EIdInvalidSocket.Create(RSCannotAllocateSocket);
  184.   end;
  185. end;
  186. procedure TIdStack.RaiseSocketError(const AErr: integer);
  187. begin
  188.   (*
  189.     RRRRR    EEEEEE   AAAA   DDDDD         MM     MM  EEEEEE    !!  !!  !!
  190.     RR  RR   EE      AA  AA  DD  DD        MMMM MMMM  EE        !!  !!  !!
  191.     RRRRR    EEEE    AAAAAA  DD   DD       MM MMM MM  EEEE      !!  !!  !!
  192.     RR  RR   EE      AA  AA  DD  DD        MM     MM  EE
  193.     RR   RR  EEEEEE  AA  AA  DDDDD         MM     MM  EEEEEE    ..  ..  ..
  194.     Please read the note in the next comment.
  195.   *)
  196.   raise EIdSocketError.CreateError(AErr, WSTranslateSocketErrorMsg(AErr));
  197.   (*
  198.     It is normal to receive a 10038 exception (10038, NOT others!) here when
  199.     *shutting down* (NOT at other times!) servers (NOT clients!).
  200.     If you receive a 10038 exception here please see the FAQ at:
  201.     http://www.nevrona.com/Indy/FAQ.html
  202.     If you get a 10038 exception here, and HAVE NOT read the FAQ and ask about this in the public
  203.     forums
  204.     you will be publicly flogged, tarred and feathered and your name added to every chain
  205.     letter in existence today.
  206.     If you insist upon requesting help via our email boxes on the 10038 error that is already
  207.     answered in the FAQ and you are simply too slothful to search for your answer and ask your
  208.     question in the public forums you may be publicly flogged, tarred and feathered and your name
  209.     may be added to every chain letter / EMail in existence today."
  210.     Otherwise, if you DID read the FAQ and have further questions, please feel free to ask using
  211.     one of the methods (Carefullly note that these methods do not list email) listed on the Tech
  212.     Support link at http://www.nevrona.com/Indy/
  213.     RRRRR    EEEEEE   AAAA   DDDDD         MM     MM  EEEEEE    !!  !!  !!
  214.     RR  RR   EE      AA  AA  DD  DD        MMMM MMMM  EE        !!  !!  !!
  215.     RRRRR    EEEE    AAAAAA  DD   DD       MM MMM MM  EEEE      !!  !!  !!
  216.     RR  RR   EE      AA  AA  DD  DD        MM     MM  EE
  217.     RR   RR  EEEEEE  AA  AA  DDDDD         MM     MM  EEEEEE    ..  ..  ..
  218.   *)
  219. end;
  220. constructor TIdStack.Create;
  221. begin
  222.   // Here so descendants can override and call inherited for future exp since TObject's Create    {Do not Localize}
  223.   // is not virtual
  224. end;
  225. class function TIdStack.CreateStack: TIdStack;
  226. begin
  227.   Result := GStackClass.Create;
  228. end;
  229. function TIdStack.ResolveHost(const AHost: string): string;
  230. begin
  231.   // Sometimes 95 forgets who localhost is
  232.   if AnsiSameText(AHost, 'LOCALHOST') then begin    {Do not Localize}
  233.     result := '127.0.0.1';    {Do not Localize}
  234.   end else if IsIP(AHost) then begin
  235.     result := AHost;
  236.   end else begin
  237.     result := WSGetHostByName(AHost);
  238.   end;
  239. end;
  240. function TIdStack.WSTranslateSocketErrorMsg(const AErr: integer): string;
  241. begin
  242.   Result := '';    {Do not Localize}
  243.   case AErr of
  244.     Id_WSAEINTR: Result           := RSStackEINTR;
  245.     Id_WSAEBADF: Result           := RSStackEBADF;
  246.     Id_WSAEACCES: Result          := RSStackEACCES;
  247.     Id_WSAEFAULT: Result          := RSStackEFAULT;
  248.     Id_WSAEINVAL: Result          := RSStackEINVAL;
  249.     Id_WSAEMFILE: Result          := RSStackEMFILE;
  250.     Id_WSAEWOULDBLOCK: Result     := RSStackEWOULDBLOCK;
  251.     Id_WSAEINPROGRESS: Result     := RSStackEINPROGRESS;
  252.     Id_WSAEALREADY: Result        := RSStackEALREADY;
  253.     Id_WSAENOTSOCK: Result        := RSStackENOTSOCK;
  254.     Id_WSAEDESTADDRREQ: Result    := RSStackEDESTADDRREQ;
  255.     Id_WSAEMSGSIZE: Result        := RSStackEMSGSIZE;
  256.     Id_WSAEPROTOTYPE: Result      := RSStackEPROTOTYPE;
  257.     Id_WSAENOPROTOOPT: Result     := RSStackENOPROTOOPT;
  258.     Id_WSAEPROTONOSUPPORT: Result := RSStackEPROTONOSUPPORT;
  259.     Id_WSAESOCKTNOSUPPORT: Result := RSStackESOCKTNOSUPPORT;
  260.     Id_WSAEOPNOTSUPP: Result      := RSStackEOPNOTSUPP;
  261.     Id_WSAEPFNOSUPPORT: Result    := RSStackEPFNOSUPPORT;
  262.     Id_WSAEAFNOSUPPORT: Result    := RSStackEAFNOSUPPORT;
  263.     Id_WSAEADDRINUSE: Result      := RSStackEADDRINUSE;
  264.     Id_WSAEADDRNOTAVAIL: Result   := RSStackEADDRNOTAVAIL;
  265.     Id_WSAENETDOWN: Result        := RSStackENETDOWN;
  266.     Id_WSAENETUNREACH: Result     := RSStackENETUNREACH;
  267.     Id_WSAENETRESET: Result       := RSStackENETRESET;
  268.     Id_WSAECONNABORTED: Result    := RSStackECONNABORTED;
  269.     Id_WSAECONNRESET: Result      := RSStackECONNRESET;
  270.     Id_WSAENOBUFS: Result         := RSStackENOBUFS;
  271.     Id_WSAEISCONN: Result         := RSStackEISCONN;
  272.     Id_WSAENOTCONN: Result        := RSStackENOTCONN;
  273.     Id_WSAESHUTDOWN: Result       := RSStackESHUTDOWN;
  274.     Id_WSAETOOMANYREFS: Result    := RSStackETOOMANYREFS;
  275.     Id_WSAETIMEDOUT: Result       := RSStackETIMEDOUT;
  276.     Id_WSAECONNREFUSED: Result    := RSStackECONNREFUSED;
  277.     Id_WSAELOOP: Result           := RSStackELOOP;
  278.     Id_WSAENAMETOOLONG: Result    := RSStackENAMETOOLONG;
  279.     Id_WSAEHOSTDOWN: Result       := RSStackEHOSTDOWN;
  280.     Id_WSAEHOSTUNREACH: Result    := RSStackEHOSTUNREACH;
  281.     Id_WSAENOTEMPTY: Result       := RSStackENOTEMPTY;
  282.   end;
  283.   Result := Format(RSStackError, [AErr, Result]);
  284. end;
  285. function TIdStack.GetIPInfo(const AIP: string; VB1: PByte = nil;
  286.   VB2: PByte = nil; VB3: PByte = nil; VB4: PByte = nil; VType: PIdIPType = nil;
  287.   VClass: PIdIPClass = nil): Boolean;
  288. var
  289.   sTemp, s1, s2, s3, s4: string;
  290.   b1, b2, b3, b4: Byte;
  291.   LType: TIdIPType;
  292.   LClass: TIdIPClass;
  293.   i: Integer;
  294.   w: Word;
  295.   c: Cardinal;
  296.   function ByteIsOk(const AByte: string; var VB: Byte): boolean;
  297.   var
  298.     i: Integer;
  299.   begin
  300.     i := StrToIntDef(AByte, -1);
  301.     Result := (i > -1) and (i < 256);
  302.     if Result then VB := Byte(i);
  303.   end;
  304.   function WordIsOk(const AWord: string; var VW: Word): boolean;
  305.   var
  306.     i: Integer;
  307.   begin
  308.     i := StrToIntDef(AWord, -1);
  309.     Result := (i > -1) and (i < 65536);
  310.     if Result then VW := Word(i);
  311.   end;
  312.   function TwentyFourBitValueIsOk(const AValue: string; var VI: Integer): boolean;
  313.   var
  314.     i: Integer;
  315.   begin
  316.     i := StrToIntDef(AValue, -1);
  317.     Result := (i > -1) and (i < 16777216);
  318.     if Result then VI := i;
  319.   end;
  320.   function LongIsOk(const ALong: string; var VC: Cardinal): boolean;
  321.   var
  322.     i: Int64;
  323.   begin
  324.     i := StrToInt64Def(ALong, -1);
  325.     Result := (i > -1) and (i < 4294967296);
  326.     if Result then VC := Cardinal(i);
  327.   end;
  328. begin
  329.   Result := False;
  330.   LType := Id_IPInvalid;
  331.   LClass := Id_IPClassUnkn;
  332.   sTemp := AIP;
  333.   s1 := Fetch(sTemp, '.');    {Do not Localize}
  334.   s2 := Fetch(sTemp, '.');    {Do not Localize}
  335.   s3 := Fetch(sTemp, '.');    {Do not Localize}
  336.   s4 := sTemp;
  337.   if s2 = '' then
  338.   begin
  339.     // RL: 4/13/2003: this probably needs to be tweaked better
  340.     if LongIsOk(s1, c) then
  341.     begin
  342.       b1 := (c and $FF000000) shr 24;
  343.       b2 := (c and $00FF0000) shr 16;
  344.       b3 := (c and $0000FF00) shr 8;
  345.       b4 := (c and $000000FF);
  346.       LType := Id_IPNumeric;
  347.     end;
  348.   end
  349.   else if s3 = '' then
  350.   begin
  351.     // class A address
  352.     if ByteIsOk(s1, b1) and TwentyFourBitValueIsOk(s2, i) then
  353.     begin
  354.       b2 := (i and $00FF0000) shr 16;
  355.       b3 := (i and $0000FF00) shr 8;
  356.       b4 := (i and $000000FF);
  357.       LType := Id_IPDotted;
  358.       LClass := Id_IPClassA;
  359.     end
  360.   end
  361.   else if s4 = '' then
  362.   begin
  363.     // class B address
  364.     if ByteIsOk(s1, b1) and ByteIsOk(s2, b2) and WordIsOk(s3, w) then
  365.     begin
  366.       b3 := (w and $FF00) shr 8;
  367.       b4 := (w and $00FF);
  368.       LType := Id_IPDotted;
  369.       LClass := Id_IPClassB;
  370.     end
  371.   end
  372.   else
  373.   begin
  374.     // class C-E address
  375.     if ByteIsOk(s1, b1) and ByteIsOk(s2, b2) and
  376.       ByteIsOk(s3, b3) and ByteIsOk(s4, b4) then
  377.     begin
  378.       LType := Id_IPDotted;
  379.       Case b1 of
  380.         0..127:   LClass := Id_IPClassA;
  381.         128..191: LClass := Id_IPClassB;
  382.         192..223: LClass := Id_IPClassC;
  383.         224..239: LClass := Id_IPClassD;
  384.       else
  385.         LClass := Id_IPClassE;
  386.       end
  387.     end
  388.   end;
  389.   if LType <> Id_IPInvalid then
  390.   begin
  391.     if (VB1 <> nil) then begin
  392.       VB1^ := b1;
  393.     end;
  394.     if (VB2 <> nil) then begin
  395.       VB2^ := b2;
  396.     end;
  397.     if (VB3 <> nil) then begin
  398.       VB3^ := b3;
  399.     end;
  400.     if (VB4 <> nil) then begin
  401.       VB4^ := b4;
  402.     end;
  403.     Result := True;
  404.   end;
  405.   if (VType <> nil) then begin
  406.     VType^ := LType;
  407.   end;
  408.   if (VClass <> nil) then begin
  409.     VClass^ := LClass;
  410.   end;
  411. end;
  412. function TIdStack.GetIPType(const AIP: string): TIdIPType;
  413. begin
  414.   GetIPInfo(AIP, nil, nil, nil, nil, @Result);
  415. end;
  416. function TIdStack.GetIPClass(const AIP: string): TIdIPClass;
  417. begin
  418.   GetIPInfo(AIP, nil, nil, nil, nil, nil, @Result);
  419. end;
  420. function TIdStack.IsIP(const AIP: string): boolean;
  421. begin
  422.   Result := not IPIsType(AIP, Id_IPInvalid);
  423. end;
  424. function TIdStack.IPIsType(const AIP: string; const AType: TIdIPType): boolean;
  425. begin
  426.   Result := GetIPType(AIP) = AType;
  427. end;
  428. function TIdStack.IPIsType(const AIP: string; const ATypes: array of TIdIPType): boolean;
  429. var
  430.   i: Integer;
  431.   LType: TIdIPType;
  432. begin
  433.   Result := False;
  434.   LType := GetIPType(AIP);
  435.   for i := Low(ATypes) to High(ATypes) do begin
  436.     if LType = ATypes[i] then begin
  437.         Result := True;
  438.         Break;
  439.     end;
  440.   end;
  441. end;
  442. function TIdStack.IPIsClass(const AIP: string; const AClass: TIdIPClass): boolean;
  443. begin
  444.   Result := GetIPClass(AIP) = AClass;
  445. end;
  446. function TIdStack.IPIsClass(const AIP: string; const AClasses: array of TIdIPClass): boolean;
  447. var
  448.   i: Integer;
  449.   LClass: TIdIPClass;
  450. begin
  451.   Result := False;
  452.   LClass := GetIPClass(AIP);
  453.   for i := Low(AClasses) to High(AClasses) do begin
  454.     if LClass = AClasses[i] then begin
  455.         Result := True;
  456.         Break;
  457.     end;
  458.   end;
  459. end;
  460. function TIdStack.IsDottedIP(const AIP: string): boolean;
  461. begin
  462.   Result := IPIsType(AIP, Id_IPDotted);
  463. end;
  464. function TIdStack.IsNumericIP(const AIP: string): boolean;
  465. begin
  466.   Result := IPIsType(AIP, Id_IPNumeric);
  467. end;
  468. destructor TIdStack.Destroy;
  469. begin
  470.   FLocalAddresses.Free;
  471.   inherited;
  472. end;
  473. function TIdStack.StringToTInAddr(AIP: string): TIdInAddr;
  474. begin
  475.   TranslateStringToTInAddr(AIP, result);
  476. end;
  477. { TIdSocketList }
  478. class function TIdSocketList.CreateSocketList: TIdSocketList;
  479. Begin
  480.   Result := GSocketListClass.Create;
  481. End;//
  482. end.