在iOS和Mac OS X之间进行双向通信的最简单方法是什么? [英] What's the most simple way to bi-directional communication between iOS and Mac OS X?

查看:70
本文介绍了在iOS和Mac OS X之间进行双向通信的最简单方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将2个NSStream用于上/下声道.但是,它看起来有些复杂.如果您知道更简单的方法(或建议),请告诉我!

I'm considering using 2 NSStream for up/down channels. However, it looks somewhat complex. If you know simpler way (or recommendations) to do this, please let me know!

-编辑-

  1. 这是内部/内部遥控器的一种快速原型.低延迟是最好的,但不是必需的.
  2. 二进制格式的数据,但不是那么繁重.它们大多数是短控制消息,有时是很大的一块.
  3. 可可/可可触感.平台仅限于它们.
  4. 两个对等点位于LAN或至少WiFi网络上.因此,我可以假设连接基本上是快速的.
  5. 与未知主机的兼容性,高效/高性能/可靠性等都无需考虑.现在,简单最重要.
  1. This is a kind of fast prototyping of internal/in-house remote controller. Low latency is best, but not required.
  2. Binary formatted data, but not so heavy. Most of them are short control messages, and sometimes big chunks exceptionally.
  3. On Cocoa / Cocoa touch. Platforms are limited to them.
  4. Two peers are on LAN or at least WiFi network. So I can assume the connection is basically fast.
  5. Compatibility to unknown hosts, high efficiency/performance/reliability and such things are no need to be considered. Just simplicity is most important now.

推荐答案

在不知道可接受的延迟,数据量,数据类型和/或网络拓扑(相同的LAN?通过WAN路由吗?)的情况下,

Without knowing acceptable latency, amount of data, type of data, and/or network topology (same LAN? routing over WAN?), it is impossible to say.

对于大多数用途,HTTP提供了一个巨大而通用的锤子. HTTP几乎受所有支持.

For most purposes, HTTP provides an awfully big and versatile hammer. And HTTP is supported by just about everything.

您想简单吗?没有什么比HTTP更加简单了,仅仅是因为它是一个无处不在的高级协议,每个人都实现了从高级API(例如NSHTTP */NSURL *)到不到1美元的嵌入式芯片的任何地方.

You want simple? Nothing is as simple as HTTP simply because it is a ubiquitous high level protocol that everyone and there brother has implemented anywhere from high level APIs (like NSHTTP*/NSURL*) down to less-than-$1 embedded chips.

如果要控制的设备具有HTTP服务器的选项,请执行该操作.当使用像HTTP这样的高级协议时,调试将变得非常简单,并且调试要容易得多.

If the devices you want to control have an option for an HTTP server, go for that. It'll be dead simple and debugging is much much easier when working with a high level protocol like HTTP.

在这一点上,很难购买带有LAN/wLAN端口并且也没有HTTP服务器的设备(在我的头上,我的家庭影院)接收器,太阳能控制器,烧烤,打印机,安全摄像机,PS3,VOIP盒和U-verse路由器都具有HTTP服务器.

At this point, it is hard not to buy a device with a LAN/wLAN port that doesn't also have an HTTP server in it (off the top of my head, my home theater receiver, solar controller, bbq, printer, security camera, PS3, VOIP box, and U-verse router all have HTTP servers).

但是,非Cocoa Touch方面的要求可能另有规定.

However, the requirements on your non-Cocoa Touch side may dictate otherwise.

这篇关于在iOS和Mac OS X之间进行双向通信的最简单方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆