         #if DEBUG
             NSLog("CocoaMQTT: socketDidSecure")
         #endif
-        let frame = CocoaMQTTFrameConnect(client: self)
-        send(frame)
-        reader!.start()
+        sendConnectFrame()
     }
 
     public func socket(sock: GCDAsyncSocket!, didWriteDataWithTag tag: Int) {

                sock.startTLS([kCFStreamSSLPeerName: self.host])
            #endif
        } else {
            let frame = CocoaMQTTFrameConnect(client: self)
            send(frame)
            reader!.start()
        }
        
        delegate?.mqtt(self, didConnect: host, port: Int(port))
    }
    
    public func socket(sock: GCDAsyncSocket!, didReceiveTrust trust: SecTrust!, completionHandler: ((Bool) -> Void)!) {

        socket!.writeData(NSData(bytes: data, length: data.count), withTimeout: -1, tag: tag)
    }

    func sendConnectFrame() {
        let frame = CocoaMQTTFrameConnect(client: self)
        send(frame)
        reader!.start()
        delegate?.mqtt(self, didConnect: host, port: Int(port))
    }

    //AsyncSocket Delegate

    public func socket(sock: GCDAsyncSocket!, didConnectToHost host: String!, port: UInt16) {
