0

I have a very simple TCP client/server implementation using GCDAsyncSocket (7.5.0) and I'm using NSNetService for service discovery. It's used only on a local wifi network and it works for 2 years with no problem (just to say : I have a proper use of GCDAsyncSocket).

...Until I tried using a third iOS device as access point providing the wifi network to which the client and server connect.

Same when the third iOS device connects both client and server by sharing its connection via Bluetooth.

The service discovery is OK, but once I get the ip address and port, I can't connect and get this error :

Error Domain=NSPOSIXErrorDomain Code=64 "Host is down" UserInfo={NSLocalizedDescription=Host is down, NSLocalizedFailureReason=Error in connect() function}

I tried restricting to IPv4 and IPv6 (both are provided by the service discovery), I also tried using the ipv6 git branch of the GCDAsyncSocket repository and various parameters.

My primary question is : is establishing a simple TCP connexion over a wifi or bluetooth iOS access point possible, if so how ?

My secondary question is : why does the NSNetService service discovery work and not the simple TCP connection ? I know that the protocols are not comparable but still, it confuses me.

4

1 回答 1

1

在我看来,您的问题在于蜂窝网络的连接。连接到蜂窝网络时,会导致 IP 地址出现问题。请参阅Cocoaasyncsocket Github 页面中的此讨论。

于 2016-10-15T04:19:15.437 回答