 
     // MARK: - Socket connection
 
-    private func socketConnect(host: String, port: Int) -> Bool {
+    private func socketConnect(host: String, port: Int, useTLS: Bool) -> Bool {
         Stream.getStreamsToHost(withName: host, port: port, inputStream: &inputStream, outputStream: &outputStream)
 
         guard let input = inputStream, let output = outputStream else {
             return false
+        }
+
+        if useTLS {
+            input.setProperty(StreamSocketSecurityLevel.tlSv1, forKey: .socketSecurityLevelKey)
+            output.setProperty(StreamSocketSecurityLevel.tlSv1, forKey: .socketSecurityLevelKey)
         }
 
         input.open()

        self.pingInterval = pingInterval
    }

    func connect() -> Bool {
        guard
            let host = host, let port = port
            else { return false }

            return false
        }

        if !socketConnect(host: host, port: port, useTLS: useTLS) {
            return false
        }

