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
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.
I think you already answered your question... you have to download an app to do this. I use "Air Sharing" and it works fine.
Related
I am a front end web developer.
I would like a web server on my local wifi network for testing my websites on my phone. I am aware that there are several options out there but witch one would be best for quick testing of multiple websites (also a GUI would be preferable)
Thanks
What you want to do is pretty complex. You have to create and configure a DNS server then you have to configure your phone to get this DNS, etc.
If your phone is an android the best solution is to use your USB Cable and put your phone in dev mode, then you can debug your site with chrome directly on your phone.
how to: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/
For iPhone i don't know if is possible. But the common solution is to use the simulator.
I'm completely new to the iPhone, so this is a newbie question.
The web development environment I use at work is set up on Windows 7, running Tomcat as a web server. Web Apps are tested by pointing a browser to "localhost".
I've been asked to port a web front end to the iPhone. Since I need to use this same development environment I need to connect the iPhone to the PC via USB or Ethernet.
There is this answer:
"http://stackoverflow.com/questions/3132105/how-do-you-access-a-website-running-on-localhost-from-iphone-browser"
but I was hoping to do it without wireless.
Other questions I've researched are about iPhone development, the SDK, etc. I'm not developing iPhone code, only trying to get the iPhone Safari browser to access the IP address of the local PC, 192.168.xx.xx or whatever.
Seems like it should be simple, a matter of cabling?
it would be an issue of cabling... if the iPhone had an eternet jack :)
But the wifi connection is the only "network jack" the phone has that you can connect to your own network directly with, the 3G or CDMA port gets routed via your mobile phone company, nothing you can do about that. Hence the need for WiFi to access non-routable addresses, like ...
Another option would be to make your server internet-routable, like middapark said. Then you can access it via your mobile phone provider's network and the public internet and can do away with the need to use Wifi.
A third option is to create a VPN tunnel from your iPhone to your local network, again via your mobile phone provider's network and the public internet. But I have no expereince with doing that, so I can not give further advice there.
The problem is most likely because you're trying to get your iPhone to view an internal (i.e.: not internet viewable) network. (Address such as 192.168.0.0, 172.16.0.0 and 10.0.0.0 and are non-routable as far as the internet as a whole is concerned.)
As such, unless you can access your internal network via wifi (or you're prepared to expose the machine in question to the internet, in which case you'll need to use a different IP address) this isn't possible.
I want to create an iPhone application that can call web services on a computer, and then upload those files over the iPhone 3g connection. Is there an elegant way to do this?
I tried connecting the phone to local Wifi, but connecting to Wifi disables 3g, even though the Wifi is local network only.
I assume the same problem would arise if I could network the phone with the computer via bluetooth.
Any other ideas? The purpose is to go up to a special demo PC we created, pull some data off, then upload to the Internet, all within proximity of the machine. Unfortunately, it appears that I can't use one connection for pulling data, and another for pushing.
Your assumption is correct. When connecting to both 3G and Wifi, the Wifi connection will be used. Sounds like your local network has no route to the Internet. Perhaps that could be fixed.
Apple does not prefer its iPhones to be used as routers.
If you're working on something that will not be distributed through the App Store, you may have some success looking at "tethering" applications and their source code, which can be found by some clever Googling.
I'm trying to do a sort of network discovery using the iPhone.
By that I mean I want for example a list of all the computers in the LAN that the iPhone is connected by wireless, and the list should contain the ip's and MAC addresses of any powered on computers that may be in the LAN.
What's the best approach on this?
(any code would be appreciated)
Thanks
Consider trying to implement netstat on the device. You'll want to use reachability to ensure that you're only checking when the device is on a LAN.
Depending on the network, consider using Apple's bonjour service to discover services running on networked computers.
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NetServices/Introduction.html
Like Jeremy said above, you could look into using Bonjour. I'm not too familiar with Bonjour, so I'm not sure if it will pick up on every machine on a LAN, or if it will only pick up devices that have published services via Bonjour, like printer sharing or SMB file shares.
That said, it's probably a good place to get started, as the Apple docs have some good code samples. In particular, you may be interested in the NSNetServices and CFNetServices Programming Guide: CFNetServices - Browsing For Services article. There's a code sample there ;-)
I have developed an iPhone app which stores photos in the /Documents directory of my app.
I would like to add a feature which gives to the user the opportunity to transfer those pictures to his/her PC or Mac.
I don't really know how to do that.
What is the best way, using Bonjour, bluetooth, or directly USB (if it is possible) ?
I really need some advices on that point ...
Any ideas ?
PS: Forgive my English, I am French :-)
Try NSNetService to register the service in Bonjour, and NSFileHandle to send data over a socket connection associated with the service.
If you do not want to write a Mac or PC part for your app then you can also consider to build in a little http server that people can use to access the data in your app. There are some nice open source http servers available for Cocoa which you can find with Google.
Using Bonjour you can advertise your http server so that people can easily find it with a Bonjour enabled browser like Safari. (Your iPhone app's web server will appear automatically under the dynamic bonjour bookmarks items)
You've edited the question to say that it's about transferring photos. Could you store the photos on the iPhone's photo roll with UIImageWriteToSavedPhotosAlbum(), and let Apple handle getting them onto the computer?
Bonjour!
I mean that both as a greeting and an answer. You have to setup a bonjour connection over wifi to transfer files directly to and from an app. That's actually pretty simple to do on both the iPhone and Mac side. The PC is a little tougher.
You can do bluetooth but bluetooth capability is still fairly rare on desktops.
Without knowing more about your specific application, I agree with Graham Lee--either directly saving to the Camera Roll or giving the user an option to save one or more photos to the Camera Roll is much simpler than http/bonjour.