Indy 9 | Content | Index | Reference

TIdTCPClient
Hierarchy, Properties, Methods, Events, See Also, Unit: IdTCPClient
Implement a TCP Client.

    TIdTCPClient = class(TIdTCPConnection)

Unit
IdTCPClient
Description
TIdTCPClient encapsulates a complete TCP (Transmission Control Protocol) client including socks support. TIdTCPClient can be used for as an ancestor class for specific protocol implementations. Many Indy client components, such as TIdDayTime, TIdEcho, TIdFinger, TIdFTP, TIdGopher, TIdHTTP, TIdNNTP, TIdPOP3, TIdQUOTD, TIdSMTP, TIdTelnet, and TIdWhois are TIdTCPClient descendants.

TIdTCPClient.BoundIP
TIdTCPClient, See Also
Specifies the IP address to use for the client.

    property BoundIP: string;

Description
BoundIP is a String property that specifies the local IP address to be used for the client connection. BoundIP is used in Connect to indicate the bound IP address for the IOHandlerSocket.ConnectClient method.

TIdTCPClient.BoundPort
TIdTCPClient, See Also
Indicates the preferred port number for the local connection.

    property BoundPort: Integer;

Description
BoundPort is an Integer property that specifies the local port number to be used for the client connection. BoundPort is used in Connect to indicate the preferred port number for the IOHandlerSocket.ConnectClient method. BoundPortMin and BoundPortMax indicate the range of port numbers available for selection when BoundPort contains the default value BoundPortDefault.

TIdTCPClient.BoundPortMax
TIdTCPClient, See Also
Indicates the highest port number for the local connection when using default port assignment.

    property BoundPortMax: Integer;

Description
BoundPortMax is an Integer property that specifies the highest local port number to be used for the client connection when using default port assignment. BoundPortMax is used in Connect to indicate the upper range for BoundPort in the IOHandlerSocket.ConnectClient method. Use BoundPortMin to indicate the lower range of port numbers available for selection when BoundPort contains the default value BoundPortDefault.

TIdTCPClient.BoundPortMin
TIdTCPClient, See Also
Indicates the lowest port number for the local connection when using default port assignment.

    property BoundPortMin: Integer;

Description
BoundPortMin is an Integer property that specifies the lowest local port number to be used for the client connection when using default port assignment. BoundPortMin is used in Connect to indicate the lower range for BoundPort in the IOHandlerSocket.ConnectClient method. Use BoundPortMax to indicate the upper range of port numbers available for selection when BoundPort contains the default value BoundPortDefault.

TIdTCPClient.Host
TIdTCPClient
Address of the remote computer system.

    property Host: string;

Description
Host is a String property that identifies the address of the remote computer system that will act as the endpoint for the client connection. The address can be a computer name such as "wvnvm.wvnet.edu" or an IP Address such as "129.71.2.4". To Connect to a server on your machine, use an IP address like "127.0.0.1" aka "localhost".

TIdTCPClient.OnConnected
TIdTCPClient, See Also
Event handler signalled on a successful connection request.

    property OnConnected: TNotifyEvent;

Description
OnConnected is a TNotifyEvent event handler used to triggerd an event notification that the client connection has been established opened in Connect. OnConnected is signalled after the IOHandler has been assigned and/or opened using the values indicated in the Host, Port, BoundIP, BoundPort, BoundPortMin, and BoundPortMax properties. OnConnected also occurs after the optional handler in Intercept has been activated for the connection.

Applications must assign a procedure to the event handler to allow responding to the event notification.

TIdTCPClient.Port
TIdTCPClient
Port number used for the server connection.

    property Port: integer;

Description
Port is an Integer property that identifies the server port number server used for the client connection. By convention, some internet protocols reserve port number including:

- 21 - FTP

- 25 - SMTP

- 80 - HTTP

- 119 - NNTP

A client application may define it's own port to connect to a server running the same port.

TIdTCPClient.Connect
TIdTCPClient, See Also
Opens the connection for the client.

    procedure Connect(const ATimeout: Integer = IdTimeoutDefault); virtual;

Description
Connect is a procedure that attempts to open the client connection to a server. Connect requires a host name (address) in Host and the port number in Port to establish a connection. Many protocol implementations override this method to provide special initialization sequences required by the protocol.

A client connection will be established using the IOHandler for the connection with BoundIP and BoundPort as the local IP address and port number for the client. An EIdAlreadyConnected exception will be raised if the IOHandler has already established a connection for the client. The IOHandler is used to default local port number assignment when BoundPort contains the value BoundPortDefault. The IOHandler also uses SocksInfo and the timeout value in ATimeout when opening the connection.

If an exception is raised in the method, Connect calls DisconnectSocket prior to re-raising the exception.

TIdTCPClient.ConnectAndGetAll
TIdTCPClient, See Also
Opens a connection and reads all data.

    function ConnectAndGetAll: string; virtual;

Return Value
String - Values read from the connection.
Description
ConnectAndGetAll is a String function that opens a connection to the server specified by Host using the port number specified by Port. ConnectAndGetAll reads data from the connection until disconnected by the server.

Make sure that the protocol you are using behaves in this manner before using ConnectAndGetAll. Quote of the Day and DayTime are examples of protocols where ConnectAndGetAll is supported.

TIdTCPClient.Create
TIdTCPClient, See Also
Constructor for the object instance.

    constructor Create(AOwner: TComponent); override;

Parameters
AOwner: TComponent
Owner of the object instance.
Description
Create is the constructor for TIdTCPClient, and relies on the inherited Create method in TIdTCPConnection. Create allocates the TIdSocksInfo instance used in the SocksInfo property, and sets BoundPort to the default value BoundPortDefault.

TIdTCPClient.Destroy
TIdTCPClient, See Also
Frees the object instance.

    destructor Destroy; override;

Description
Destroy is the destructor for object instance. Destroy is responsible for freeing resources allocates in the Create constructor prior to calling the inherited Destroy method.

Created with Doc-O-Matic 2 donated to Project JEDI. Commercial license available from the Doc-O-Matic site.