I just need to send a basic message with via UDP. I already gave up and I guess I have to use some of the libraries out there. As I research there are examples of the AsyncUdpSocket library. I don't know where I can download that class and I end up finding GCDAsyncUdpSocket. Aparently they have a different constructor and that is the reason why I am not able to instantiate a new object in order to send a udp message. I know the basics of objective c and I will appreciate if someone can show me a short example of how to broadcast a message. the server part I already got I am just interested in the client part.
First download GCDAsyncUdpSocket from here. Then you may send packets as:
GCDAsyncUdpSocket *udpSocket ; // create this first part as a global variable
udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
NSData *data = [[NSString stringWithFormat:@"Hello World"] dataUsingEncoding:NSUTF8StringEncoding];
[udpSocket sendData:data toHost:@"192.168.10.111" port:550 withTimeout:-1 tag:1];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With