Ad Hoc Wifi Connection Between iPhone & Mac - Possible?

六月ゝ 毕业季﹏ 提交于 2019-11-28 14:09:12

You can make use of Bonjour, via NSNetServices and CFNetServices APIs.

Basically:

  1. Create a server on the Mac
  2. Announce the server via Bonjour
  3. Browse Bonjour on the phone and resolve the bonjour service.
  4. Establish connection
  5. Exchange data via socket streams

You cannot automagically do this, yet. That is, you must manually create the ad hoc wireless network (a "computer-to-computer network" in Apple parlance) first on the Mac, then join the iPhone to it just like any other WiFi network. After this, the methods suggested above will work just fine.

What I think you are suggesting, also known as WiFi Direct, is a very new specification that is not yet supported by the iPhone or OS X (as of this writing).

You'd probably want to look at NSNetServices/CFNetServices (Bonjour) for a common API to accomplish that sort of connection.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!