It seems like Martin R’s answer should work, however I was able to get the socket to stay open with a single function call. At the end of the startServer() function, I put the line:
CFRunLoopRun()
Which worked.
More Related Contents:
- Wait until swift for loop with asynchronous network requests finishes executing
- Waiting until the task finishes
- How do I dispatch_sync, dispatch_async, dispatch_after, etc in Swift 3, Swift 4, and beyond?
- How to stop a DispatchWorkItem in GCD?
- dispatch_once after the Swift 3 GCD API changes
- Whither dispatch_once in Swift 3?
- How can I create a reference cycle using dispatchQueues?
- Use queue and semaphore for concurrency and property wrapper?
- How to convert a date string with optional fractional seconds using Codable in Swift?
- Swift double to string
- Attach parameter to button.addTarget action in Swift
- What enables SwiftUI’s DSL?
- Flatten an Array of Arrays in Swift
- Xcode 8 Beta 3 Use Legacy Swift issue
- Real time NSTask output to NSTextView with Swift
- Difference between == and ===
- How can I change the textual representation displayed for a type in Swift?
- Instance member cannot be used on type of custom class
- How change background color if using NavigationView in SwiftUI?
- What does the dollar sign do in Swift / SwiftUI?
- Convert Float to Int in Swift
- Using DateFormatter on a Unix timestamp
- Type conversion when using protocol in Swift
- How do I see which version of Swift I’m using?
- Using ‘self’ in class extension functions in Swift
- Swift 4 Decodable – Dictionary with enum as key
- Why .pch file not available in swift?
- iOS11 swift silent push (background fetch, didReceiveRemoteNotification) is not working anymore
- Is there a correct way to determine that an NSNumber is derived from a Bool using Swift?
- NEHotspotHelper.register not received call back iOS11