0

How to create thread to listen server through cocoaasyncsocket in ios app

I am using cocoaasyncSocket from here: cocoaAsyncSocket

i try sample code and push this code into AppDelegate.h and AppDelegate.m but when i am connected, this app don't receive any data send from server. I want my app auto receive data from server after connected

rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

To receive data from the other peer of the socket you should call a read method. It can be readDataWithTimeout. When you receive data from server - (void)socket:(GCDAsyncSocket *)sock didReadData:(NSData *)data withTag:(long)tag delegate method will be fired.

Boran
  • 949
  • 10
  • 17
  • i put method in appdelegate.. is that true?...but i seem nothing to fired when server push data back – user3548621 Apr 18 '14 at 14:56
  • I think, you should first try with cocoaAsyncSocket's connectTest sample. Try to make proper changes to connect to your server. – Boran Apr 21 '14 at 06:07