One thing I found unintuitive about GCDAsyncSocket's didReadData callback is that it doesn't get call again unless you issue another readData. Why is it designed this way? Is it correct to expect the user of the library to initiate another read call in order to get a callback or is this a design flaw?
e.g.
- (void)socket:(GCDAsyncSocket *)sock didAcceptNewSocket:(GCDAsyncSocket *)newSocket {
...
// initiate the first read
self.socket = newSocket;
[self.socket readDataWithTimeout:-1 tag:0];
}
- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag {
// do what you need with the data...
// read again, or didReadData won't get called!
[self.socket readDataWithTimeout:-1 tag:0];
}