         }
         services = [HHService]()
     }
+    fileprivate var lastInterfaceNameChosenForConnect: String?
     open var keepaliveTimer: Timer?
     open var lastReceivedData: Date = Date.init(timeIntervalSince1970: 0)
     open var connect: (()->Void)?

        peer.connect = {
            do {
                // pick the address to connect to INSIDE the block, because more addresses may have been added between announcement and inviteBlock being executed
                guard let hhaddresses = peer.pickedResolvedService()?.resolvedAddressInfo, hhaddresses.count > 0, var chosenAddress = hhaddresses.filter({ $0.isCandidateAddress(bluetoothOnly: limitToBluetooth) }).first else {
                    DLog("connect: \(peer.displayName) has no resolvedAddresses or candidates after invite accepted/rejected, BAILING")
                    return
                }
                
                // if we can use wifi, then use wifi if possible
                if !self.bluetoothOnly && !chosenAddress.isWifiInterface() {
                    let wifiCandidates = hhaddresses.filter({ $0.isCandidateAddress(bluetoothOnly: self.bluetoothOnly) && $0.isWifiInterface() })
                    if wifiCandidates.count > 0 {
                        chosenAddress = wifiCandidates.first!
                    }
                }
                
                DLog("connect: \(peer.displayName) has \(peer.services.count) svcs (\(peer.resolvedServices().count) resolved); picked service has \(hhaddresses.count) addresses, chose \(chosenAddress.addressAndPortString) on interface \(chosenAddress.interfaceName)")
                let sockdata = chosenAddress.socketAsData()
                

        peer.socket = nil
        sock.synchronouslySetDelegate(nil)
        
        switch oldState {
        case .authenticated:
            peer.disconnectCount += 1
            self.dispatch_on_delegate_queue({
                self.membershipRosterDelegate?.peerDidDisconnect?(peer.role, peer: peer, canConnectNow: self.canConnectNow(peer))
            })
        case .notConnected:
            assert(false, "ERROR: state is being tracked wrong")
