         }
     }
     
-    public func socket(_ sock: GCDAsyncSocket, didWriteDataWithTag tag: Int) {
-        guard let peer = sock.peer else {
-            return
-        }
-        self.scheduleNextKeepaliveTimer(peer)
-    }
+//    public func socket(_ sock: GCDAsyncSocket, didWriteDataWithTag tag: Int) {
+//        guard let peer = sock.peer else {
+//            return
+//        }
+//        self.scheduleNextKeepaliveTimer(peer)
+//    }
     
     public func socket(_ sock: GCDAsyncSocket, didReadPartialDataOfLength partialLength: UInt, tag: Int) {
         guard let peer = sock.peer else {

            var senddata = NSData.init(data: self.keepAliveHeader) as Data
            senddata.append(self.headerTerminator)
            self.logDelegate?.didReadWrite("writeKeepAlive")
            peer.socket?.write(senddata, withTimeout: Timeouts.header.rawValue, tag: DataTag.tag_WRITING.rawValue)
            NSLog("BluepeerObject: send keepAlive to \(peer.displayName) @ \(peer.socket?.connectedHost)")
        }

            if peer.state != .connected || peer.socket == nil {
                return
            }

            peer.lastReceivedData = Date.init()

            if peer.keepaliveTimer?.isValid == true {
                return
            }

            let delay: TimeInterval = Timeouts.keepAlive.rawValue - 5 - (Double(arc4random_uniform(5000)) / Double(1000)) // keepAlive.rawValue - 5 - (up to 5)
            NSLog("BluepeerObject: keepalive INITIAL SCHEDULING for \(peer.displayName) in \(delay)s")
            peer.keepaliveTimer = Timer.scheduledTimer(timeInterval: delay, target: self, selector: #selector(self.keepAliveTimerFired), userInfo: ["peer":peer], repeats: true)
        })
    }
    
