Class TTCPBlockSocket

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TTCPBlockSocket = class(TSocksBlockSocket)

Description

Implementation of TCP socket.

Supported features: IPv4, IPv6, SSL/TLS or SSH (depending on used plugin), SOCKS5 proxy (outgoing connections and limited incomming), SOCKS4/4a proxy (outgoing connections and limited incomming), TCP through HTTP proxy tunnel.

Hierarchy

Overview

Methods

Public constructor Create;
Public constructor CreateWithSSL(SSLPlugin: TSSLClass);
Public destructor Destroy; override;
Public procedure CloseSocket; override;
Public function WaitingData: Integer; override;
Public procedure Listen; override;
Public function Accept: TSocket; override;
Public procedure Connect(IP, Port: string); override;
Public procedure SSLDoConnect;
Public procedure SSLDoShutdown;
Public function SSLAcceptConnection: Boolean;
Public function GetLocalSinIP: string; override;
Public function GetRemoteSinIP: string; override;
Public function GetLocalSinPort: Integer; override;
Public function GetRemoteSinPort: Integer; override;
Public function SendBuffer(Buffer: TMemory; Length: Integer): Integer; override;
Public function RecvBuffer(Buffer: TMemory; Len: Integer): Integer; override;
Public function GetSocketType: integer; override;
Public function GetSocketProtocol: integer; override;
Published function GetErrorDescEx: string; override;

Properties

Public property SSL: TCustomSSL read FSSL;
Public property HTTPTunnel: Boolean read FHTTPTunnel;
Published property HTTPTunnelIP: string read FHTTPTunnelIP Write FHTTPTunnelIP;
Published property HTTPTunnelPort: string read FHTTPTunnelPort Write FHTTPTunnelPort;
Published property HTTPTunnelUser: string read FHTTPTunnelUser Write FHTTPTunnelUser;
Published property HTTPTunnelPass: string read FHTTPTunnelPass Write FHTTPTunnelPass;
Published property HTTPTunnelTimeout: integer read FHTTPTunnelTimeout Write FHTTPTunnelTimeout;
Published property OnAfterConnect: THookAfterConnect read FOnAfterConnect write FOnAfterConnect;

Description

Methods

Public constructor Create;

Create TCP socket class with default plugin for SSL/TSL/SSH implementation (see SSLImplementation)

Public constructor CreateWithSSL(SSLPlugin: TSSLClass);

Create TCP socket class with desired plugin for SSL/TSL/SSH implementation

Public destructor Destroy; override;
 
Public procedure CloseSocket; override;

See TBlockSocket.CloseSocket

Public function WaitingData: Integer; override;

See TBlockSocket.WaitingData

Public procedure Listen; override;

Sets socket to receive mode for new incoming connections. It is necessary to use TBlockSocket.Bind function call before this method to select receiving port!

If you use SOCKS, activate incoming TCP connection by this proxy. (By BIND method of SOCKS.)

Public function Accept: TSocket; override;

Waits until new incoming connection comes. After it comes a new socket is automatically created (socket handler is returned by this function as result).

If you use SOCKS, new socket is not created! In this case is used same socket as socket for listening! So, you can accept only one connection in SOCKS mode.

Public procedure Connect(IP, Port: string); override;

Connects socket to remote IP address and PORT. The same rules as with TBlockSocket.Bind method are valid. The only exception is that PORT with 0 value will not be connected. After call to this method a communication channel between local and remote socket is created. Local socket is assigned automatically if not controlled by previous call to TBlockSocket.Bind method. Structures TBlockSocket.LocalSin and TBlockSocket.RemoteSin will be filled with valid values.

If you use SOCKS, activate outgoing TCP connection by SOCKS proxy specified in TSocksBlockSocket.SocksIP. (By CONNECT method of SOCKS.)

If you use HTTP-tunnel mode, activate outgoing TCP connection by HTTP tunnel specified in HTTPTunnelIP. (By CONNECT method of HTTP protocol.)

Note: If you call this on non-created socket, then socket is created automaticly.

Public procedure SSLDoConnect;

If you need upgrade existing TCP connection to SSL/TLS (or SSH2, if plugin allows it) mode, then call this method. This method switch this class to SSL mode and do SSL/TSL handshake.

Public procedure SSLDoShutdown;

By this method you can downgrade existing SSL/TLS connection to normal TCP connection.

Public function SSLAcceptConnection: Boolean;

If you need use this component as SSL/TLS TCP server, then after accepting of inbound connection you need start SSL/TLS session by this method. Before call this function, you must have assigned all neeeded certificates and keys!

Public function GetLocalSinIP: string; override;

See TBlockSocket.GetLocalSinIP

Public function GetRemoteSinIP: string; override;

See TBlockSocket.GetRemoteSinIP

Public function GetLocalSinPort: Integer; override;

See TBlockSocket.GetLocalSinPort

Public function GetRemoteSinPort: Integer; override;

See TBlockSocket.GetRemoteSinPort

Public function SendBuffer(Buffer: TMemory; Length: Integer): Integer; override;

See TBlockSocket.SendBuffer

Public function RecvBuffer(Buffer: TMemory; Len: Integer): Integer; override;

See TBlockSocket.RecvBuffer

Public function GetSocketType: integer; override;

Return value of socket type. For TCP return SOCK_STREAM.

Public function GetSocketProtocol: integer; override;

Return value of protocol type for socket creation. For TCP return IPPROTO_TCP.

Published function GetErrorDescEx: string; override;

Return descriptive string for LastError. On case of error in SSL/TLS subsystem, it returns right error description.

Properties

Public property SSL: TCustomSSL read FSSL;

Class implementing SSL/TLS support. It is allways some descendant of TCustomSSL class. When programmer not select some SSL plugin class, then is used TSSLNone

Public property HTTPTunnel: Boolean read FHTTPTunnel;

True if is used HTTP tunnel mode.

Published property HTTPTunnelIP: string read FHTTPTunnelIP Write FHTTPTunnelIP;

Specify IP address of HTTP proxy. Assingning non-empty value to this property enable HTTP-tunnel mode. This mode is for tunnelling any outgoing TCP connection through HTTP proxy server. (If policy on HTTP proxy server allow this!) Warning: You cannot combine this mode with SOCK5 mode!

Published property HTTPTunnelPort: string read FHTTPTunnelPort Write FHTTPTunnelPort;

Specify port of HTTP proxy for HTTP-tunneling.

Published property HTTPTunnelUser: string read FHTTPTunnelUser Write FHTTPTunnelUser;

Specify authorisation username for access to HTTP proxy in HTTP-tunnel mode. If you not need authorisation, then let this property empty.

Published property HTTPTunnelPass: string read FHTTPTunnelPass Write FHTTPTunnelPass;

Specify authorisation password for access to HTTP proxy in HTTP-tunnel mode.

Published property HTTPTunnelTimeout: integer read FHTTPTunnelTimeout Write FHTTPTunnelTimeout;

Specify timeout for communication with HTTP proxy in HTTPtunnel mode.

Published property OnAfterConnect: THookAfterConnect read FOnAfterConnect write FOnAfterConnect;

This event is called after sucessful TCP socket connection.


Generated by PasDoc 0.9.0 on 2012-04-23 21:38:50