The development of watch app socket application cannot be connected to the Internet

I am using the latest Xcode to develop the Watch APP

No third party libraries are used in the project

Joined only import network

I am trying to use Socket for TCP port communication.

When I debug and run in the simulator, the network communication is normal.

But when I debug with the real Watch5GPS version, I find that I ca n’t connect to the Internet.

Console feedback


2020-01-29 01:28:22.334097+0800 test WatchKit Extension[268:15120] [] [C1 ip:80 tcp, indefinite, prefer companion] is already cancelled, ignoring cancel

2020-01-29 01:28:22.334177+0800 test WatchKit Extension[268:15120] [] [C1 ip:80 tcp, indefinite, prefer companion] is already cancelled, ignoring cancel



When I change watch4, I can communicate normally.

I don't understand what happened

Replies

Using low level network APIs on watchOS outside the context of a streaming audio application will result in inconsistent behavior. Running from the simulator will provide better results because it is taking advantage of the network stack available to macOS instead of the actual physical watch device.


For more information on this, see my post about Low-Level Networking on watchOS.


Matt Eaton

DTS Engineering, CoreOS

meaton3 at apple.com