Search code examples
iphoneobjective-ciosipadcocoaasyncsocket

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


My partner and I have checked 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?


Solution

  • 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.