使用 iOS 设备作为 TCP 客户端 - 没有 Bonjour [英] Using iOS device as TCP client - no Bonjour
问题描述
我想将 iOS 设备用作 TCP 客户端,但我找不到有关如何执行此操作的可理解的 API/指南/示例.我尝试了 SimpleNetworkStreams
和 PictureSharing
,但它们都在使用 Bonjour.我可以轻松地建立 UDP 连接,通过 UDPEcho
学习,但我找不到像 UDPEcho
那样好的 TCP 示例.我想要一个连接到服务器的简单示例,并在屏幕上打印来自服务器的所有传入消息 - 就是这样.
I'd like to use iOS device as a TCP client, but I can't find an understandable API/guide/sample of how to do that. I tried SimpleNetworkStreams
and PictureSharing
, but they are both using Bonjour. I can make UDP connections easily, learned via UDPEcho
, but I can't find as good sample as UDPEcho
for TCP. I want a simple example of connecting to a server, and print in the screen all the incoming messages from the server - that's it.
谢谢!
推荐答案
你看过 AsyncSocket 项目吗?
Have you looked at the AsyncSocket project?
http://code.google.com/p/cocoaasyncsocket/
它支持 TCP 和 UDP.为了找到它,我在谷歌上搜索了cocoa tcp socket class".
It supports TCP and UDP. To find it, I googled "cocoa tcp socket class".
注意:该项目已移至 https://github.com/robbiehanson/CocoaAsyncSocket
这篇关于使用 iOS 设备作为 TCP 客户端 - 没有 Bonjour的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!