I'm opening two NSStreams pairs (input/output) between a client app and a server app, and need to associate those two streams on the same server-side object. The two stream approach means that didAcceptConnectionWithInputStream will be called twice, once for each stream open command coming from the client. Both open commands will be performed sequentially, one immediately after the other. I tried using the fact that the two opens will be done in conjunction to pair them on the server side, but there is definitely a problem with race conditions and stream confusion if two different clients attempt to connect at the same time.
What would be perfect is if there were a key/value pair that could be sent when connecting to the service, and I would send a client-generated GUID to identify the client.
Identifying by IP address, although a possible solution because the clients will be on a local network (not having to traverse a NAT), seems complex to implement with NSNetService.