Reputation: 6547
I am trying to use SwiftSockets to send data from my Mac to my iPhone.
When I try the following code
var socket = UDPClient(address: "192.168.1.158", port: 20777)
override func viewDidLoad() {
super.viewDidLoad()
let res = socket.send(data: [255])
print(res.error.debugDescription)
}
I get the message Optional(SwiftSocket.SocketError.unknownError)
and I do not receive any data from my iPhone.
What is the issue and how do I fix it?
Edit: If I try the hostname of my device, I get the following message
2018-08-27 01:28:01.893463+0100 App Name[863:10545] dnssd_clientstub ConnectToServer: connect()-> No of tries: 1
2018-08-27 01:28:02.894593+0100 App Name[863:10545] dnssd_clientstub ConnectToServer: connect()-> No of tries: 2
2018-08-27 01:28:03.894872+0100 App Name[863:10545] dnssd_clientstub ConnectToServer: connect()-> No of tries: 3
2018-08-27 01:28:04.895240+0100 App Name[863:10545] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:4 Err:-1 Errno:1 Operation not permitted
Upvotes: 0
Views: 794
Reputation: 4166
I switch from comments to the answer to add the image...
Firstly from the documentation and from the source they use the hostname instead of the IP address, it can be found under the router info clients or in the iPhone under General - Info - Name.
Then the error message seems to be a capabilities issue.
Go to capabilities and under App Sandbox
check if it is firstly enabled and then check the Network Incoming and Outcoming Connections
like in the image:
Upvotes: 1