Description | Hierarchy | Fields | Methods | Properties |
type TTCPBlockSocket = class(TSocksBlockSocket)
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.
constructor Create; |
|
constructor CreateWithSSL(SSLPlugin: TSSLClass); |
|
destructor Destroy; override; |
|
procedure CloseSocket; override; |
|
function WaitingData: Integer; override; |
|
procedure Listen; override; |
|
function Accept: TSocket; override; |
|
procedure Connect(IP, Port: string); override; |
|
procedure SSLDoConnect; |
|
procedure SSLDoShutdown; |
|
function SSLAcceptConnection: Boolean; |
|
function GetLocalSinIP: string; override; |
|
function GetRemoteSinIP: string; override; |
|
function GetLocalSinPort: Integer; override; |
|
function GetRemoteSinPort: Integer; override; |
|
function SendBuffer(Buffer: TMemory; Length: Integer): Integer; override; |
|
function RecvBuffer(Buffer: TMemory; Len: Integer): Integer; override; |
|
function GetSocketType: integer; override; |
|
function GetSocketProtocol: integer; override; |
|
function GetErrorDescEx: string; override; |
property SSL: TCustomSSL read FSSL; |
|
property HTTPTunnel: Boolean read FHTTPTunnel; |
|
property HTTPTunnelIP: string read FHTTPTunnelIP Write FHTTPTunnelIP; |
|
property HTTPTunnelPort: string read FHTTPTunnelPort Write FHTTPTunnelPort; |
|
property HTTPTunnelUser: string read FHTTPTunnelUser Write FHTTPTunnelUser; |
|
property HTTPTunnelPass: string read FHTTPTunnelPass Write FHTTPTunnelPass; |
|
property HTTPTunnelTimeout: integer read FHTTPTunnelTimeout Write FHTTPTunnelTimeout; |
|
property OnAfterConnect: THookAfterConnect read FOnAfterConnect write FOnAfterConnect; |
constructor Create; |
Create TCP socket class with default plugin for SSL/TSL/SSH implementation (see SSLImplementation)
constructor CreateWithSSL(SSLPlugin: TSSLClass); |
Create TCP socket class with desired plugin for SSL/TSL/SSH implementation
destructor Destroy; override; |
procedure CloseSocket; override; |
function WaitingData: Integer; override; |
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.)
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.
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.
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.
procedure SSLDoShutdown; |
By this method you can downgrade existing SSL/TLS connection to normal TCP connection.
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!
function GetLocalSinIP: string; override; |
See TBlockSocket.GetLocalSinIP
function GetRemoteSinIP: string; override; |
See TBlockSocket.GetRemoteSinIP
function GetLocalSinPort: Integer; override; |
See TBlockSocket.GetLocalSinPort
function GetRemoteSinPort: Integer; override; |
See TBlockSocket.GetRemoteSinPort
function SendBuffer(Buffer: TMemory; Length: Integer): Integer; override; |
function RecvBuffer(Buffer: TMemory; Len: Integer): Integer; override; |
function GetSocketType: integer; override; |
Return value of socket type. For TCP return SOCK_STREAM.
function GetSocketProtocol: integer; override; |
Return value of protocol type for socket creation. For TCP return IPPROTO_TCP.
function GetErrorDescEx: string; override; |
Return descriptive string for LastError
. On case of error in SSL/TLS subsystem, it returns right error description.
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
property HTTPTunnel: Boolean read FHTTPTunnel; |
True
if is used HTTP tunnel mode.
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!
property HTTPTunnelPort: string read FHTTPTunnelPort Write FHTTPTunnelPort; |
Specify port of HTTP proxy for HTTP-tunneling.
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.
property HTTPTunnelPass: string read FHTTPTunnelPass Write FHTTPTunnelPass; |
Specify authorisation password for access to HTTP proxy in HTTP-tunnel mode.
property HTTPTunnelTimeout: integer read FHTTPTunnelTimeout Write FHTTPTunnelTimeout; |
Specify timeout for communication with HTTP proxy in HTTPtunnel mode.
property OnAfterConnect: THookAfterConnect read FOnAfterConnect write FOnAfterConnect; |
This event is called after sucessful TCP socket connection.