开发者

Sending UDP packets from the iPhone

开发者 https://www.devze.com 2023-01-24 11:33 出处:网络
Does anyone have any good tutorials on sending UDP pack开发者_JAVA技巧ets from the iPhone SDK? EDIT:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消