WebSocket naming convention - Network Framework

Hi,
I'm using Network Framework to make a peer-to-peer WebSocket connection between two devices. I'm currently setting up my Listener:
Code Block swift
class TapListener {
    let userID: UserID
    init(userID: UserID) {
        self.userID = userID
        startListening()
    }
    func startListening() {
        do {
            let parameters = NWParameters.tls
            parameters.includePeerToPeer = true
            let webSocketOptions = NWProtocolWebSocket.Options()
            webSocketOptions.autoReplyPing = true            parameters.defaultProtocolStack.applicationProtocols.insert(webSocketOptions, at: 0)
            let listener = try NWListener(using: parameters)
            listener.service = NWListener.Service(type: "_tapit._websocket",
                                                  domain: "local",
                                                  txtRecord: userID.data())
(rest of code)
        } catch {
            log("Failed to create listener")
            abort()
        }
    }
}

I was wondering, should the type of the service be
Code Block swift
"_tapit._websocket"
or
Code Block swift
"_tapit._tcp"
I found very little documentation regarding naming conventions with WebSocket, so I'm asking just to make sure!

P.S: Is it necessary for me to specify the domain?

Thanks in advance!


Answered by Claude31 in 642626022
Have you tried both ? A first guess is that tcp should be more appropriate.

Did you see here how to discover existing services ?
https://stackoverflow.com/questions/45999930/bonjour-search-for-a-service-by-name

Is domain "local" or "local." ?
It is an optional parameter, so I guess local is by default.
Accepted Answer
Have you tried both ? A first guess is that tcp should be more appropriate.

Did you see here how to discover existing services ?
https://stackoverflow.com/questions/45999930/bonjour-search-for-a-service-by-name

Is domain "local" or "local." ?
It is an optional parameter, so I guess local is by default.
WebSocket naming convention - Network Framework
 
 
Q