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.
精彩评论