I'm successfully using the following code to send a UDP-message to a server:
GCDAsyncUdpSocket *udpSocket;
udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
NSData *data = [@"initialize" dataUsingEncoding:NSUTF8StringEncoding];
[udpSocket sendData:data toHost:@"127.0.0.1" port:5000 withTimeout:-1 tag:1];
When the server receives this message it replies with a series of responses. How can I catch and process those? I want my app to listen to server-responses on the same port it sent the outgoing message for 2 minutes and then repeat the initialize-message in an endless loop:
message -> listen -> message -> listen ...