xcode Objective-C 中的 WebSocket 使用示例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8304485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 22:35:13  来源:igfitidea点击:

Example of WebSocket Usage in Objective-C

iphoneobjective-ciosxcodewebsocket

提问by Jhon Smith

I've been trying for some time now, unsuccessfully, to connect to a local server via WebSockets in Objective-C (specifically, iPhone) code. I have tried the following three libraries, all with no success:

我已经尝试了一段时间,但没有成功,通过 Objective-C(特别是 iPhone)代码中的 WebSockets 连接到本地服务器。我尝试了以下三个库,但都没有成功:

http://code.google.com/p/unitt/wiki/UnittWebSocketClient

http://code.google.com/p/unitt/wiki/UnittWebSocketClient

https://github.com/zootreeves/iOS-WebSockets

https://github.com/zootreeves/iOS-WebSockets

and zimt.

和 zimt。

With zimt, I was unable to even include the files in my project without encountering any errors.

使用 zimt,我什至无法在没有遇到任何错误的情况下将文件包含在我的项目中。

I was wondering if someone could please post some sample code that just simply connects to a server and performs a successful handshake/login. It would be great if I could be given working code to finally determine if the issue is the way the server is set up or not.

我想知道是否有人可以发布一些示例代码,这些代码只是简单地连接到服务器并执行成功的握手/登录。如果我能得到工作代码来最终确定问题是否是服务器的设置方式,那就太好了。

I greatly appreciate any help, thank you!

我非常感谢任何帮助,谢谢!

回答by mikelikespie

Try SocketRocket, we just released it. It is RFC 6455compliant. Has some example code too.

试试SocketRocket,我们刚刚发布了它。它符合RFC 6455。也有一些示例代码。