             if name == nil {
                 name = "Unknown"
             }
-            name = name?.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines)
-            peer.displayName = name!
+            name = name!.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) // sender pads with spaces to 32 bytes
+            peer.displayName = self.sanitizeCharsToDNSChars(str: name!) // probably unnecessary but need to be safe
+            
+            // we're the server. If we are advertising and browsing for the same serviceType, there's a duplicate peer situation to take care of -- one created by browsing, one when socket was accepted. Remedy: kill old one, keep this one
+            for existingPeer in self.peers.filter({ $0.displayName == peer.displayName && $0 != peer }) {
+                if let indexOfPeer = self.peers.index(of: existingPeer) {
+                    DLog("BluepeerObject: removing dupe peer \(self.peers[indexOfPeer].displayName) from index \(indexOfPeer), had socket: \(self.peers[indexOfPeer].socket != nil ? "ACTIVE" : "nil")")
+                    self.peers.remove(at: indexOfPeer)
+                }
+                self.bailOn(socket: existingPeer.socket, peer: existingPeer)
+                peer.dnsService?.endResolve()
+                peer.dnsService = nil
+                peer.announced = false
+                peer.keepaliveTimer?.invalidate()
+                peer.keepaliveTimer = nil
+            }
             
             if let delegate = self.membershipAdminDelegate {
                 self.dispatch_on_delegate_queue({

        }
    }
    
    open func disconnectSession() {
        // don't close serverSocket: expectation is that only stopAdvertising does this
        // loop through peers, disconenct all sockets

        }
    }
    
    fileprivate func bailOn(socket: GCDAsyncSocket?, peer: BPPeer) {
        peer.state = .notConnected
        socket?.synchronouslySetDelegate(nil)
        socket?.disconnect()
        peer.socket = nil
    }
    
    public func socket(_ sock: GCDAsyncSocket, didRead data: Data, withTag tag: Int) {
        
//        DLog("socket reads: \(data.hex)")
