 import CocoaAsyncSocket // NOTE: requires pod CocoaAsyncSocket
 import HHServices
 import dnssd
+import xaphodObjCUtils
 
 let kDNSServiceInterfaceIndexP2PSwift = UInt32.max-2
+let iOS_wifi_interface = "en0"
 
 // "Any" means can be both a client and a server. If accepting a new connection from another peer, that peer is deemed a client. If found an advertising .any peer, that peer is considered a server.
 @objc public enum RoleType: Int, CustomStringConvertible {

                peer.dataRecvCount += existingPeer.dataRecvCount
                peer.dataSendCount += existingPeer.dataSendCount
//                existingPeer.destroyServices()
                peer.services.append(contentsOf: existingPeer.services)
                existingPeer.keepaliveTimer?.invalidate()
                existingPeer.keepaliveTimer = nil

                // We have N candidateAddresses from 1 resolved service, which should we pick?
                // if we tried to connect to one recently and failed, and there's another one, pick the other one
                var interimAddress: HHAddressInfo?
                if let lastInterfaceName = peer.lastInterfaceName, candidateAddresses.count > 1 {
                    let otherAddresses = candidateAddresses.filter { $0.interfaceName != lastInterfaceName }
                    if otherAddresses.count > 0 {
                        interimAddress = otherAddresses.first!
                        DLog("connect: \(peer.displayName) trying a different interface than last attempt. Now trying: \(interimAddress!.interfaceName)")
