Skip to content

SSH.Session.Connect

Andrew Lambert edited this page Nov 26, 2022 · 10 revisions

SSH.Session.Connect

Method Signatures

 Function Connect(Address As String, Port As Integer, TimeOut As UInt32 = 0) As Boolean
 Function Connect(Socket As TCPSocket, TimeOut As UInt32 = 0) As Boolean

Parameters

Connect(String, Integer, UInt32)

Name Type Comment
Address String The IP address or hostname to connect to.
Port Integer The port to connect to.
TimeOut UInt32 Optional. The length of time to wait for the TCP socket to connect (in milliseconds).

Connect(TCPSocket, UInt32)

Name Type Comment
Socket TCPSocket The socket to use for establishing the session.
TimeOut UInt32 Optional. The length of time to wait for the TCP socket to connect (in milliseconds).

Return value

Returns True if the SSH session has been successfully established. Check Session.LastError and Session.LastErrorMsg for details if this method returns False.

Remarks

Initiates an SSH session, either with the Address and Port parameters to open a new socket, or with the Socket parameter to use an existing connection. If you pass a TCPSocket that is not already connected then the TCPSocket.Address and TCPSocket.Port properties must be set to the address/port of the SSH server.

The Address may be a fully qualified domain name or an IPv4 address. IPv6 addresses can't be used until/unless IPv6 support is added to the Xojo TCPSocket class. (See Xojo Feedback case #18253; <feedback://showreport?report_id=18253>)

If the TCP connection has not yet failed nor succeeded within the TimeOut period then the attempt is aborted and Session.LastError is set to ERR_TIMEOUT_ELAPSED(-509).

The default TimeOut period is zero, which means no time out. The underlying TCPSocket may still (eventually) time out, however, in which case Session.LastError will be the Xojo socket error code negated (e.g. -103 is a name resolution error.)

This method does not check the host's fingerprint or send the user's credentials.

See also

Clone this wiki locally