如何构建/安装/运行服务器程序来与 iPhone 通信?
我想尝试创建一个服务器程序,通过套接字连接与 iPhone 应用程序进行通信。我在 Apple 的客户端编程文档中找到了几个指南(使用 CFNetwork、NSStream 等),但我不知道从哪里开始对服务器应用程序进行编程,甚至不知道要使用什么语言,或者就此而言,如何通过 GoDaddy 在我当前的网络托管包上部署并运行服务器应用程序。一个简单的即时通讯风格的应用程序示例应该可以帮助我入门,但任何建议都会受到赞赏。
I'd like to play with the idea of creating a server program that communicates with an iPhone app over socket connections. I've found several guides within Apple's documentation for client side programming (with CFNetwork, NSStream, etc) but I don't know where to begin on programming the server application, or even what language to use, or for that matter, how to deploy and run a server application on my current web hosting package through Go Daddy. A simple instant messenger style application example should get me started, but any advice is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果你想创建套接字连接最好使用 CFNetwork ,它对你来说有更大的灵活性我已经使用过 NSURLConnection 但 CFNetwork 具有更好的性能。这是我的步骤以及我如何开发我的应用程序:
但我在向服务器发送和接收消息并形成服务器时遇到了一些问题。所以我把它改成了 CF 类,现在效果更好更快了。
if you want to create socket connection is better to use CFNetwork , it has more flexibility for you I already used NSURLConnection but CFNetwork has better performance. this is my steps and how I developed my app :
but I had some problems in sending and receiving message to and form server . so I changed it to CF classes it works better and faster now.
处理服务器到设备通信的最简单方法是使用 APNS(Apple 推送通知服务)。
另一个方向(设备到服务器)的通信可以通过 NSUrlConnection。
如果您想为此编写自己的套接字代码,那么祝您好运。
The easiest way to handle server-to-device communications is to use APNS (Apple Push Notification Services).
Communication in the other direction (device-to-server) can be handled simply with NSUrlConnection.
If you want to write your own socket code for this, well - good luck with that.
您希望您的客户端应用程序能够在多个操作系统上运行吗?如果是这样,你可能不想接触任何苹果特有的东西。不过,如果您确实想在 iOS 上运行,使用 MusiGenesis 的建议可以节省您大量时间。
我发现 Python 和 Perl 都非常适合套接字编程。我知道 Python 有几个内置的库用于处理 HTTP 请求等。如果你想将你的服务器作为守护进程运行,我发现这段代码非常有用:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
这是一个通用的 python 套接字指南:
http://docs.python.org/howto/sockets.html
祝你好运。
Do you want your client application to be able to run on more than one OS? If so, you might want to stay clear of anything Apple specific. Although, if you strictly want to run on iOS, using MusiGenesis' suggestion could save you a ton of time.
I have found that Python and Perl are both pretty great for socket programming. I know that Python has several libraries built in for handling HTTP requests etc. If you want to run your server as a daemon, I found this code very helpful:
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
Here is a general python sockets guide:
http://docs.python.org/howto/sockets.html
Good luck.