I have two applications installed on the same device and they trying to connect to a multicast group the first application has a succeed connection the second one has error : listener failed with error Group entered state failed(POSIXErrorCode(rawValue: 48): Address already in use) I thought that allowLocalEndpointReuse allows several clients to connect to the same port
but it doesn't work.
let port = NWEndpoint.Port(portUdp) ?? NWEndpoint.Port(5353)
let host = NWEndpoint.Host(urlUdp)
guard let multicast = try? NWMulticastGroup(for:
[ .hostPort(host: host, port: port) ])
else {
stateMultiCast = "Error with url and port"
return
}
let parameters = NWParameters.udp
parameters.allowLocalEndpointReuse = true
parameters.allowLocalEndpointReuse
let group = NWConnectionGroup(with: multicast, using: parameters)
group.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: true)
{ (message, content, isComplete) in .... }
group.stateUpdateHandler = { (newState) in
print("Group entered state \(String(describing: newState))")
}
group.start(queue: .main)
How can i use the same port for several application so this application can receive all the same message sent by udp server ?
Thank you for your help