Skip to content

Commit 6986a9b

Browse files
committed
Make this compile and run on Linux
1 parent f4be0c5 commit 6986a9b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/NetServiceStreams.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@ import Foundation
2929
return CFSocketError(kCFSocketError)
3030
}
3131
let sock = CFSocketGetNative(s)
32-
return CFDataGetBytePtr(address).withMemoryRebound(to: sockaddr.self, capacity: 1) { (addr: UnsafePointer<sockaddr>!) -> CFSocketError in
33-
guard addr != nil else { return CFSocketError(kCFSocketError) }
34-
guard bind(sock, addr, len) == 0,
35-
listen(sock, 256) == 0 else { return CFSocketError(errno) }
36-
return CFSocketError(kCFSocketSuccess)
37-
}
32+
guard let a = CFDataGetBytePtr(address) else { return CFSocketError(kCFSocketError) }
33+
let addr = UnsafeRawPointer(a).assumingMemoryBound(to: sockaddr.self)
34+
guard bind(sock, addr, len) == 0,
35+
listen(sock, 256) == 0 else { return CFSocketError(errno) }
36+
return CFSocketError(kCFSocketSuccess)
3837
}
3938
#else
4039
private let utf8 = CFStringBuiltInEncodings.UTF8.rawValue
@@ -110,6 +109,7 @@ public class DNSSDNetServiceOutputStream: OutputStream {
110109
public typealias PropertyValue = AnyObject
111110

112111
public required init(toMemory: ()) {
112+
sock = -1
113113
super.init(toMemory: ())
114114
}
115115
#else

0 commit comments

Comments
 (0)