diff --git a/Sources/NetService/FoundationCompat.swift b/Sources/NetService/FoundationCompat.swift index eebcade..59bcb78 100644 --- a/Sources/NetService/FoundationCompat.swift +++ b/Sources/NetService/FoundationCompat.swift @@ -1,5 +1,9 @@ import CoreFoundation +#if !os(Linux) || compiler(>=5.3) +internal let kCFSocketReadCallBack = CFSocketCallBackType.readCallBack.rawValue +#endif + #if os(Linux) && !compiler(>=5.0) import class Foundation.RunLoop import struct Foundation.RunLoopMode diff --git a/Sources/NetService/NetService.swift b/Sources/NetService/NetService.swift index d501c20..a1e262f 100644 --- a/Sources/NetService/NetService.swift +++ b/Sources/NetService/NetService.swift @@ -356,7 +356,7 @@ public class NetService { var context = CFSocketContext(version: 0, info: info, retain: nil, release: nil, copyDescription: nil) - socket = CFSocketCreateWithNative(nil, fd, CFOptionFlags(CFSocketCallBackType.readCallBack.rawValue), _processResult, &context) + socket = CFSocketCreateWithNative(nil, fd, CFOptionFlags(kCFSocketReadCallBack), _processResult, &context) // Don't close the underlying socket on invalidate, as it is owned by dns_sd. var socketFlags = CFSocketGetSocketFlags(socket) diff --git a/Sources/NetService/NetServiceBrowser.swift b/Sources/NetService/NetServiceBrowser.swift index 23f365f..6ac9a0a 100644 --- a/Sources/NetService/NetServiceBrowser.swift +++ b/Sources/NetService/NetServiceBrowser.swift @@ -178,7 +178,7 @@ public class NetServiceBrowser { let info = Unmanaged.passUnretained(self).toOpaque() var context = CFSocketContext(version: 0, info: info, retain: nil, release: nil, copyDescription: nil) - socket = CFSocketCreateWithNative(nil, fd, CFOptionFlags(CFSocketCallBackType.readCallBack.rawValue), _processResult, &context) + socket = CFSocketCreateWithNative(nil, fd, CFOptionFlags(kCFSocketReadCallBack), _processResult, &context) // Don't close the underlying socket on invalidate, as it is owned by dns_sd. var socketFlags = CFSocketGetSocketFlags(socket)