iPhone Objective-C 套接字与 Socket.IO 通信

发布于 2024-10-16 20:21:11 字数 1436 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

羅雙樹 2024-10-23 20:21:11

编辑于 2015/03/19: Socket.IO 人员创建了他们自己的支持 Socket.IO v1.0+ 的 iOS 库。在这里获取它: https://github.com/socketio/socket.io-client- swift


旧答案

我更新了fpotter的socket.io库以使用版本0.7.2 - 0.9.x
它支持套接字和 XHRpolling。

https://github.com/pkyeck/socket.IO-objc

也许你想要检查一下。

edited 2015/03/19: The Socket.IO guys created their own iOS library that supports Socket.IO v1.0+. Get it here: https://github.com/socketio/socket.io-client-swift


old answer

I updated fpotter's socket.io library to work with version 0.7.2 - 0.9.x.
It supports sockets and XHRpolling.

https://github.com/pkyeck/socket.IO-objc

Maybe you want to check it out.

唯憾梦倾城 2024-10-23 20:21:11

或者看看 cocoaasyncsocket

CocoaAsyncSocket支持 TCP 和 UDP。 AsyncSocket 类用于 TCP,
AsyncUdpSocket 类用于
UDP。每个类的描述如下。

AsyncSocket 是 TCP/IP 套接字
包装 CFSocket 的网络库
和CFStream。它提供了异步
操作和原生可可类
并得到代表的支持。这里
主要特点是:

  • 排队的非阻塞读取和写入,具有可选的超时。你
    告诉它读什么或写什么,以及
    完成后它会打电话给你。

  • 自动套接字接受。如果你告诉它接受连接,它会为每个连接调用你自己的新实例。当然,您可以立即断开它们。

  • 代表支持。错误、连接、接受、读取完成、写入完成、进度和断开连接都会导致对委托方法的调用。

  • 基于运行循环,而不是基于线程。尽管您可以在主线程或工作线程上使用它,但您不必这样做。它使用 NSRunLoop 异步调用委托方法。委托方法包含一个套接字参数,允许您区分多个实例。

  • 独立于一类。您无需浪费时间处理流或套接字。类句柄
    所有这些。

  • 支持 IPv4 和 IPv6 上的 TCP 流。

图书馆是公共领域,
最初由达斯汀·沃斯撰写。现在
可在公共场合使用,以允许
并鼓励其继续支持。

AsyncUdpSocket 是一个 UDP/IP 套接字网络库,它封装了
CFSocket。它的工作原理几乎完全一样
TCP版本,但是被设计成
专门用于UDP。这包括
排队非阻塞发送/接收
运营、全力代表支持、
基于运行循环的独立类,
并支持 IPv4 和 IPv6。

Or have a look at cocoaasyncsocket:

CocoaAsyncSocket supports TCP and UDP. The AsyncSocket class is for TCP,
and the AsyncUdpSocket class is for
UDP. Each class is described below.

AsyncSocket is a TCP/IP socket
networking library that wraps CFSocket
and CFStream. It offers asynchronous
operation, and a native cocoa class
complete with delegate support. Here
are the key features:

  • Queued non-blocking reads and writes, with optional timeouts. You
    tell it what to read or write, and
    it will call you when it's done.

  • Automatic socket acceptance. If you tell it to accept connections, it will call you with new instances of itself for each connection. You can, of course, disconnect them immediately.

  • Delegate support. Errors, connections, accepts, read completions, write completions, progress, and disconnections all result in a call to your delegate method.

  • Run-loop based, not thread based. Although you can use it on main or worker threads, you don't have to. It calls the delegate methods asynchronously using NSRunLoop. The delegate methods include a socket parameter, allowing you to distinguish between many instances.

  • Self-contained in one class. You don't need to muck around with streams or sockets. The class handles
    all of that.

  • Support for TCP streams over IPv4 and IPv6.

The library is public domain,
originally written by Dustin Voss. Now
available in a public setting to allow
and encourage its continued support.

AsyncUdpSocket is a UDP/IP socket networking library that wraps
CFSocket. It works almost exactly like
the TCP version, but is designed
specifically for UDP. This includes
queued non-blocking send/receive
operations, full delegate support,
run-loop based, self-contained class,
and support for IPv4 and IPv6.

最偏执的依靠 2024-10-23 20:21:11

如果您打算制作本机应用程序,我建议您查看有关流式传输和套接字的 Apple 文档。 http://developer.apple.com/library/ ios/#documentation/cocoa/Conceptual/Streams/Streams.html

I'd suggest checking out the Apple documentation for streaming and sockets if you are planning on doing an native app. http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/Streams/Streams.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文