Gcdasynsocket did read data delegate dosent give correct tag value <p>I am using gcdasynsocket to establish socket communication. Below shown is the method that i am using to write the data</p> <pre><code>-(void)writeData:(NSData*)data withTag:(int)tag { [asyncSocket writeData:data withTimeout:-1.0 tag:tag]; [asyncSocket readDataWithTimeout:-1.0 tag:tag]; } - (void)socket:(GCDAsyncSocket *)sock didWriteDataWithTag:(long)tag { if (tag == 18) { NSLog(@"First request sent"); [asyncSocket readDataWithTimeout:-1.0 tag:18]; } else if (tag == 125) { NSLog(@"Second request sent"); [asyncSocket readDataWithTimeout:-1.0 tag:125]; } } </code></pre> <p>//reading the data</p> <pre><code>- (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag { NSLog(@"tag---%ld",tag); } </code></pre> <p>In my did read data delegate i am not getting the tag value what i have passed. Since i am not getting the correct tag value. i couldnt read my another data. I am not sure what is going wrong here. Please help me to fix this issue</p>