Sending UDP packets from the iPhone
Does anyone have any good tutorials on sending UDP pack开发者_JAVA技巧ets from the iPhone SDK?
EDIT:
Was actually really easy to do this...
RTFM!
After including AsyncUdpSocket just add this in header:
AsyncUdpSocket *socket;
And in main:
NSData *data = ...
[socket sendData:data toHost:@"192.168.x.x" port:5002 withTimeout:-1 tag:1];
When testing don't forget to allow UDP communication on your server firewall!
CocoaAsyncSocket is a nice library that contains a class called AsyncUdpSocket
which is an Obj-C wrapper around the lower-level socket API.
You can use the CFNetwork framwork to create a UDP socket with CFSocket. Here is the CFSocket reference.
精彩评论