Delphi IdTCPClient[1] 介绍、属性、方法

1、介绍

实现TCP客户端。TIdTCPClient封装了一个完整的TCP(传输控制协议)客户端,包括socks支持。TIdTCPClient可以用作特定协议实现的祖先类。许多Indy客户端组件,如TIdDayTime、TIdEcho、TIdFinger、TIdFTP、TIdGopher、TIdPHTTP、TIdNNTP、TIdPOP3、TIdQUOT、TIdSMTP、TIdTelnet和TIdWhois都是TIdTCPClient的后代

unit IdTCPClient;

interface

uses
  Classes, IdStack,
  IdException, IdGlobal, IdTCPConnection;

const
  BoundPortDefault = 0;

type
  TIdTCPClient = class(TIdTCPConnection)
  protected
    FBoundIP: string;
    FBoundPort: Integer;
    FBoundPortMax: Integer;
    FBoundPortMin: Integer;
    FHost: string;
    FOnConnected: TNotifyEvent;
    FPassword: string;
    FPort: integer;
    FUsername: string;
    //
    procedure SetHost(const Value: string); virtual;
    procedure SetPort(const Value: integer); virtual;
    procedure DoOnConnected; virtual;
    //
    property Username: string read FUsername write FUsername;
    property Password: string read FPassword write FPassword;
  public
    procedure Connect(const ATimeout: Integer = IdTimeoutDefault); virtual;
    function ConnectAndGetAll: string; virtual;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    //
    property BoundPortMax: Integer read FBoundPortMax write FBoundPortMax;
    property BoundPortMin: Integer read FBoundPortMin write FBoundPortMin;
  published
    property BoundIP: string read FBoundIP write FBoundIP;
    property BoundPort: Integer read FBoundPort write FBoundPort default BoundPortDefault;
    property Host: string read FHost write SetHost;
    property OnConnected: TNotifyEvent read FOnConnected write FOnConnected;
    property Port: integer read FPort write SetPort;
  end;

implementation

uses
  IdComponent, IdIOHandlerSocket, IdResourceStrings,
  SysUtils;

2、属性:

  • BoundIP
  • BoundPort
  • BoundPortMax
  • BoundPortMin
  • Host
  • OnConnected
  • Port

TIdTCPConnection

  • ASCIIFilter
  • ClosedGracefully
  • Greeting
  • InputBuffer
  • Intercept
  • IOHandler
  • LastCmdResult
  • MaxLineAction
  • MaxLineLength
  • OnDisconnected
  • OnWork
  • OnWorkBegin
  • OnWorkEnd
  • ReadLnSplit
  • ReadLnTimedOut
  • ReadTimeout
  • RecvBufferSize
  • SendBufferSize
  • Socket

TIdComponent

  • LocalName

TIdBaseComponent

  • Version

3、方法

TIdTCPClient

  • Connect
  • ConnectAndGetAll
  • Create
  • Destroy

TIdTCPConnection

  • AllData
  • CancelWriteBuffer
  • procedure Capture(ADest: TStream; const ADelim: string = ‘.’; const AIsRFCMessage: Boolean = True); overload;
  • procedure Capture(ADest: TStream; out VLineCount: Integer; const ADelim: string = ‘.’; const AIsRFCMessage: Boolean = True); overload;
  • procedure Capture(ADest: TStrings; const ADelim: string = ‘.’; const AIsRFCMessage: Boolean = True); overload;
  • procedure Capture(ADest: TStrings; out VLineCount: Integer; const ADelim: string = ‘.’; const AIsRFCMessage: Boolean = True); overload;
  • CheckForDisconnect
  • CheckForGracefulDisconnect
  • CheckResponse
  • ClearWriteBuffer
  • CloseWriteBuffer
  • Connected
  • Create
  • CurrentReadBuffer
  • Destroy
  • Disconnect
  • DisconnectSocket
  • FlushWriteBuffer
  • GetInternalResponse
  • function GetResponse(const AAllowedResponses: array of SmallInt): SmallInt; virtual; overload;
  • function GetResponse(const AAllowedResponse: SmallInt): SmallInt; overload;
  • InputLn
  • OpenWriteBuffer
  • procedure RaiseExceptionForLastCmdResult; virtual; overload;
  • procedure RaiseExceptionForLastCmdResult(AException: TClassIdException); virtual; overload;
  • ReadBuffer
  • ReadCardinal
  • ReadChar
  • ReadFromStack
  • ReadInteger
  • ReadLn
  • ReadLnWait
  • ReadSmallInt
  • ReadStream
  • ReadString
  • ReadStrings
  • function SendCmd(const AOut: string; const AResponse: SmallInt = -1): SmallInt; overload;
  • function SendCmd(const AOut: string; const AResponse: Array of SmallInt): SmallInt; virtual; overload;
  • WaitFor
  • Write
  • WriteBuffer
  • WriteCardinal
  • WriteFile
  • WriteHeader
  • WriteInteger
  • WriteLn
  • WriteRFCReply
  • WriteRFCStrings
  • WriteSmallInt
  • WriteStream
  • WriteStrings

TIdComponent

  • BeginWork
  • Create
  • Destroy
  • DoWork
  • EndWork

TIdBaseComponent

  • GetVersion

4、事件

  • OnStatus     //OnStatus是当前连接状态更改时触发的TIdStatusEvent事件处理程序。OnStatus由DoStatus方法触发,该方法提供事件处理程序使用的参数。axStatus是当前连接的TIdStatus值。aaArgs是Format函数的可选参数,用于构造表示当前连接状态的文本消息。

 

 

 

 

创建时间:2022.11.21  更新时间:

原文地址:http://www.cnblogs.com/guorongtao/p/16910688.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性