开发者

AsyncSocket works on my simulator but not my partner's - connection cancelled error

开发者 https://www.devze.com 2023-04-05 00:47 出处:网络
My partner and I have ch开发者_运维技巧ecked out the exact same code, and we are both using the same network.

My partner and I have ch开发者_运维技巧ecked out the exact same code, and we are both using the same network.

When I try and connect to a socket using AsyncSocket, it works. When my partner does the exact same thing, it does not.

I have tried Googling but I have no traction. Any tips?


The answer to this questions is as follows.

When implementing the following delegate function, we did not return a value:

- (BOOL)onSocketWillConnect:(AsyncSocket *)sock;

If you don't expicitly return a value, what this function actually returns on any given device is non-deterministic (or at least impossible to calculate). On my machine, it happened to return true, and on my partner's it was false.

As usual, paying attention to the compiler warnings would solve this problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消