tags:

views:

220

answers:

2

Hi

The iPhone settings have an IP address for the device when it is connected to a wifi network. Is it possible to get this IP address and establish a connection between a desktop computer (on the same network) and the iPhone?

I want to be able to transfer files between the iPhone and the desktop computer. Some apps like the "Files" and "FourTrack" apps do this.

Can someone please guide me to where I can start?

Thanks a lot for any headsup

A: 

I think you already answered your question... you have to download an app to do this. I use "Air Sharing" and it works fine.

John Rasch
I believe lostInTransit is asking how to implement an app such as Air Sharing.
Rob Napier
+2  A: 

Google for SIOCGIFCONF and you'll find a bunch of example code in C for getting all your IP addresses. Once you've enumerated your devices, on iPhone they are always in the following order: Loopback, WiFi, WAN.

Once you have that, you can implement a web server with CocoaHttpServer pretty easily. You'll have to hack it to add directory listings and the like, but it's not too hard. It's not trivial, but it's not too bad.

Rob Napier
Can you please elaborate. I've never done any n/w programming but i learn fast. Thanks.
lostInTransit
Hey... I've been doing it the hard way. I didn't realize getifaddrs(3) was available.... The Linux man pages for getifaddrs(3) includes example code on how to get all your IP addresses: http://www.kernel.org/doc/man-pages/online/pages/man3/getifaddrs.3.html. This should work on iPhone (I've generally used the SIOCGIFCONF approach because it's what I learned first, but getifaddrs() is much easier). Once you have your IP address, pull down cocoahttpserver (from above) and try experimenting with setting up a web server. By then you'll have more specific questions to ask.
Rob Napier