I made an iPhone client connect to a server using GCDAsyncSocket. The server is running .Net on a Windows server. The connect is good and it sends data well too.
I then tell the client to go into receive directly after the send...
[sock readDataToData:[GCDAsyncSocket LFData] withTimeout:15 tag:1];
I also have this set up to receive:
- (void)onSocket:(GCDAsyncSocket *)sock didReadData:(NSData *)data
withTag:(long)tag
and also:
- (NSTimeInterval)socket:(GCDAsyncSocket *)sock shouldTimeoutReadWithTag:(long)tag
If I wait for the time out the time out method is called.
If I send data from the server, the timeout is not called, so I assume the client has seen something, but there is no indication of that on the client side.
I also added:
- (void)socket:(GCDAsyncSocket *)sock didReadPartialDataOfLength: (NSUInteger)partialLength tag:(long)tag
hoping I would see a partial packet but this does not get triggered either.
As I mentioned above the timeout does not trigger if I send something from the server to the client. However I would have thought it would also timeout if it hasn't received the terminator character. I also tried reading with a length of 3 but that didnt make any difference.
The GCDAsyncSocket is the the problem. AsyncSocket seems to work ok.
Maybe its the init is wrong?
dispatch_queue_t mainQueue = dispatch_get_main_queue();
asyncSocket = [[GCDAsyncSocket alloc] initWithDelegate:self delegateQueue:mainQueue]
Any ideas what I did wrong?
I put a post on the goggle code for this but there isnt any activity so not sure if I will get an answer or not.
Ideally if anyone has a sample code that the receives works that would be great! thank you!