Skip to content
Snippets Groups Projects
Unverified Commit 9612c133 authored by Jake Heiser's avatar Jake Heiser Committed by GitHub
Browse files

Merge pull request #55 from SimplyKyra/add-connection-timeout

Added a timeout to the SSH init method
parents fbcae228 53e77049
Branches master
No related tags found
No related merge requests found
......@@ -45,13 +45,14 @@ public class SSH {
/// - Parameters:
/// - host: the host to connect to
/// - port: the port to connect to; default 22
/// - timeout: timeout to use (in msec); default 0
/// - Throws: SSHError if the SSH session couldn't be created
public init(host: String, port: Int32 = 22) throws {
public init(host: String, port: Int32 = 22, timeout: UInt = 0) throws {
self.sock = try Socket.create()
self.session = try Session()
session.blocking = 1
try sock.connect(to: host, port: port)
try sock.connect(to: host, port: port, timeout: timeout)
try session.handshake(over: sock)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment