                     
                     self.stopBrowsing() // stop browsing once user has done something. Destroys all HHService except this one!
                     
+                    if let oldSocket = peer.socket {
+                        NSLog("**** BluepeerObject: PEER ALREADY HAD SOCKET, DESTROYING...")
+                        oldSocket.synchronouslySetDelegate(nil)
+                        oldSocket.disconnect()
+                        peer.socket = nil
+                    }
+                    
                     peer.socket = GCDAsyncSocket.init(delegate: self, delegateQueue: self.socketQueue)
-                    peer.socket!.isIPv4PreferredOverIPv6 = false
+                    peer.socket?.isIPv4PreferredOverIPv6 = false
                     peer.state = .connecting
                     try peer.socket?.connect(toAddress: sockdata, viaInterface: chosenAddress.interfaceName, withTimeout: timeoutForInvite)
                 } catch {

    public func socketDidDisconnect(_ sock: GCDAsyncSocket, withError err: Error?) {
        guard let peerIndex = self.peers.index(where: {sock == $0.socket}) else {
            NSLog("BluepeerObject socketDidDisconnect: WARNING, expected to find a peer, calling peerConnectionAttemptFailed")
            sock.delegate = nil
            self.dispatch_on_delegate_queue({
                self.sessionDelegate?.peerConnectionAttemptFailed?(.unknown, peer: nil, isAuthRejection: false)
            })

    deinit {
        NotificationCenter.default.removeObserver(self)
        self.killAllKeepaliveTimers()
        self.disconnectSession()
        self.stopBrowsing()
        self.stopAdvertising()
        NSLog("BluepeerObject: DEINIT FINISH")
    }
    
    // Note: if I disconnect, then my delegate is expected to reconnect if needed.
