I have already read other similar question about that problem, but that don't work for me.
I'm building an iPhone app that talks with a TCP server (windows, but never mind) and I'm using AsyncSocket from cocoaasyncsocket (googlecode). It's a very useful class, but I can't use that at all.
In my code I create a "connector" which I alloc and init an AsyncSocket, so I open the TCP connection.
With an NSTimer, every second I try to read from server some data, so I send writeData
[asyncSocket writeData:[NSData dataWithBytes:buffer length:lung]
withTimeout:-1
tag:WRITE_OP];
and, when
- (void)onSocket:(AsyncSocket *)sock didWriteDataWithTag:(long)tag
raises I send [sock readDataWithTimeout:-1 tag:READ_OP];
(I try also [sock readDataToLength:numBytesToRead tag:READ_OP];, but never change..)
I read in AsyncSocket Documentation that I have to put another readDataWithTimeout:tag:
also at the end of didReadData:withTag
and also in willDisconnectWithError
, but in my app this latest method never raises.
I think that there're multiple read requests, but I try to prevent this and I don't have any other idea.
I would appreciate any help.
(Sorry for my English.) Thanks a lot!