从 iPhone 发送 UDP 数据包

编程入门 行业动态 更新时间:2024-10-22 11:32:08
本文介绍了从 iPhone 发送 UDP 数据包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有没有人有关于从 iPhone SDK 发送 UDP 数据包的好教程?

Does anyone have any good tutorials on sending UDP packets from the iPhone SDK?

其实真的很容易做到这一点...

Was actually really easy to do this...

RTFM!

在包含 AsyncUdpSocket 之后,只需在 header 中添加:

After including AsyncUdpSocket just add this in header:

AsyncUdpSocket *socket;

主要是:

NSData *data = ... [socket sendData:data toHost:@"192.168.x.x" port:5002 withTimeout:-1 tag:1];

测试时不要忘记在您的服务器防火墙上允许 UDP 通信!

When testing don't forget to allow UDP communication on your server firewall!

推荐答案

CocoaAsyncSocket 是一个不错的库,它包含一个名为 AsyncUdpSocket 的类,它是一个围绕低级套接字 API 的 Obj-C 包装器.

CocoaAsyncSocket is a nice library that contains a class called AsyncUdpSocket which is an Obj-C wrapper around the lower-level socket API.

更多推荐

从 iPhone 发送 UDP 数据包

本文发布于:2023-11-08 15:59:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1569828.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据包   iPhone   UDP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!