简体   繁体   English

如何在iOS7中的UDP套接字中发送字符串?

[英]How to send a string in a UDP socket in iOS7?

I am trying to send a simple string over UDP in my iOS7 app to a known IP and could not find a simple explanation and sample code on how to do that. 我试图在我的iOS7应用程序中通过UDP发送一个简单的字符串到一个已知的IP,并找不到一个简单的解释和示例代码如何做到这一点。 There is plenty out there about TCP but not so much about UDP and it has to be UDP in my case. 有很多关于TCP的内容,但关于UDP的内容并不多,在我的情况下它必须是UDP。

You could use https://github.com/robbiehanson/CocoaAsyncSocket , which is an Objective-C wrapper for TCP and UDP connections. 您可以使用https://github.com/robbiehanson/CocoaAsyncSocket ,它是TCP和UDP连接的Objective-C包装器。 It also contains sample code for TCP and UPD clients and servers. 它还包含TCP和UPD客户端和服务器的示例代码。

you could use this wrapper-less simple gist . 你可以使用这个无包装的简单要点 Happy networking. 快乐的网络。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM