简体   繁体   English

如何创建与 iPhone/iPad App 交互的 Mac/PC 服务器应用程序?

[英]How to create a Mac/PC server app that interacts with iPhone/iPad App?

Can someone please point me in the right direction to create a Mac/PC server app that runs in the background and connects to an iPad app over the local WiFi network?有人可以指出正确的方向来创建一个在后台运行并通过本地 WiFi 网络连接到 iPad 应用程序的 Mac/PC 服务器应用程序吗?

No matter how I phrase a search on Google it just brings up various apps like Remote Mouse and whatnot and no tutorials or even a hint of where to start.无论我如何在 Google 上进行搜索,它只会显示各种应用程序,如 Remote Mouse 之类的,没有教程,甚至没有提示从哪里开始。

I just need to send simple commands from iPad to computer over local wifi.我只需要通过本地 wifi 将简单的命令从 iPad 发送到计算机。 A point in the right direction and I can likely fill in the blanks.指向正确的方向,我很可能会填补空白。

Thank you.谢谢你。

Thomas托马斯

EDIT: I am using web languages for the iPad version that I will build as a native app using open source tools.编辑:我将 web 语言用于 iPad 版本,我将使用开源工具将其构建为本机应用程序。

OK, then.那好吧。 It actually depends on what you really need.这实际上取决于您真正需要什么。 I made the assumption you need real-time and perhaps binary data transfer.我假设您需要实时和可能的二进制数据传输。

Your best bet is to write your server application using standard C or C++ so it compiles on both as simply as possible.最好的办法是使用标准 C 或 C++ 编写服务器应用程序,以便尽可能简单地在两者上编译。 If you want to avoid all the burden of writing a protocol for service discovery or asking users to enter the ip address of your server you will use a mDNS implementation for your server and your iPhone app.如果您想避免为服务发现编写协议或要求用户输入服务器的 ip 地址的所有负担,您将为您的服务器和 iPhone 应用程序使用 mDNS 实现。

If I were you I would try bonjour: http://www.apple.com/support/bonjour/ on iPhone You could start here: http://developer.apple.com/library/mac/#documentation/Networking/Conceptual/NSNetServiceProgGuide/Articles/PublishingServices.html如果我是你,我会在 iPhone 上尝试 bonjour: http://www.apple.com/support/bonjour/你可以从这里开始: http://developer.apple.com/library/mac/#documentation/Networking/Conceptual /NSNetServiceProgGuide/Articles/PublishingServices.html

Once you have your sockets you will have to implement a networking protocol between your server application and your iPhone app.拥有 sockets 后,您必须在服务器应用程序和 iPhone 应用程序之间实现网络协议。 You will have to be careful about byte ordering and little subtle problems with latency, disconnections and other problems inherent to networking and WiFi.您必须小心字节顺序以及延迟、断开连接和其他网络和 WiFi 固有问题的细微问题。

In windows you will want to register your application as a service and in Mac OS X/UNIX you'll probably want to deamonize it.在 windows 中,您将希望将您的应用程序注册为服务,而在 Mac OS X/UNIX 中,您可能希望对其进行去恶魔化。

Good luck!祝你好运!

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

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