SwiftSocket icon indicating copy to clipboard operation
SwiftSocket copied to clipboard

UDPClient always fails with unknownError

Open MrJanssen opened this issue 6 years ago • 6 comments

The following code always fails to send a UDP message, with console output: "Client failed to send message to server: unknownError"

let udpClient = UDPClient(address: "127.0.0.1", port: 12033)  

switch udpClient.send(string: "Hello") {
case .success:
    print("Client sent message to server.")
case .failure(let error):
     print("Client failed to send message to server: \(error)")
}

udpClient.close()

Using Xcode 10.1 and Swift 4.2 macOS High Sierra 10.13.6

MrJanssen avatar Jan 23 '19 10:01 MrJanssen

I just figured this out - in your project's Capabilities settings ensure that the App Sandbox Network in and out (client and server) are enabled. 👍

nyx avatar Mar 03 '19 19:03 nyx

Using Xcode Version 10.1 (10B61) Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1) Target: x86_64-apple-darwin18.5.0 macOS Mojave 10.14.4 Beta (18E194d)

nyx avatar Mar 03 '19 20:03 nyx

This helped me! Thanks!

rustymyers avatar Apr 19 '19 14:04 rustymyers

Does it work only with paid developer program? I do not see App sandbox in my capabilities

ilyamordasov avatar Nov 14 '19 13:11 ilyamordasov

@ilyamordasov I checked the quick help on Xcode and it says "The Capability library shows only the capabilities available to the target type and your program membership. If you are not a member of the Apple Developer Program, the capabilities you can add are limited".

This might be one of those. https://developer.apple.com/documentation/xcode/adding_capabilities_to_your_app

rustymyers avatar Nov 14 '19 14:11 rustymyers

@rustymyers that's no good for me. ok, thanks :)

ilyamordasov avatar Nov 14 '19 14:11 ilyamordasov