2

I was just wondering if it is possible to set up a data transfer tunnel between an iPhone and a Mac using the Wifi hardware present on both devices? My main objective is to transfer data from my iPhone to my Mac through an app along an ad hoc wifi connection. If there are any other methods you would like to suggest, then please do.

Looking forward to your replies.

Thanks!

A.K.

AK.
  • 23
  • 1
  • 4

3 Answers3

5

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
MarkPowell
  • 16,482
  • 7
  • 61
  • 77
1

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).

Zack
  • 1,256
  • 9
  • 20
  • What is the problem in publishing a service through the Wifi hardware on the Mac and then using the iPhone to look for that service and then joining it? – AK. Jan 18 '10 at 11:09
  • No problem, per se. I just wanted to draw attention to the fact that ad hoc networking (specifically) is very problematic. Many people have asked about this on Apple Dev Forums, and in general, there is much confusion over this topic. For example, see https://devforums.apple.com/message/150607 . Maybe I read too much into your mention of ad hoc networking specifically. However, since the announcement of WiFi Direct last November, this topic has again generated much interest among iPhone developers. Sounds like you are well on your way. Happy coding! – Zack Jan 18 '10 at 17:54
0

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

nctrost
  • 49
  • 2
  • Thanks for your reply nc. I will check out these resources asap. Have you tried doing this before? If yes, were you successful in your attempt? – AK. Dec 04 '09 at 17:47