fix broadcast discovery
This commit is contained in:
parent
2b423502ec
commit
8c2219aa00
|
@ -129,11 +129,10 @@ open class UDPBroadcastConnection {
|
|||
var socketAddressLength = socklen_t(MemoryLayout<sockaddr_storage>.size)
|
||||
let response = [UInt8](repeating: 0, count: 4096)
|
||||
let UDPSocket = Int32(source.handle)
|
||||
let pointer = UnsafeMutablePointer<[UInt8]>.allocate(capacity: response.capacity)
|
||||
pointer.initialize(to: response)
|
||||
|
||||
// Do not fix pointer warning. It must work this way.
|
||||
let bytesRead = withUnsafeMutablePointer(to: &socketAddress) {
|
||||
recvfrom(UDPSocket, pointer, response.count, 0,
|
||||
recvfrom(UDPSocket, UnsafeMutableRawPointer(mutating: response), response.count, 0,
|
||||
UnsafeMutableRawPointer($0).bindMemory(to: sockaddr.self, capacity: 1), &socketAddressLength)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue