Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 03-10-2011, 07:56 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 2
davidbjames is on a distinguished road
Default How to connect iOS device to local host.

Anyone know if it's possible to make HTTP connections to your local machine from a USB-connected (via XCode) iOS device? Rather critical if you plan on developing an API for your app (seems like a common scenario). I tried disabling WiFi hoping it would fall back on the computer's connection, but no go. <edit>I should explain that my computer and iOS device both use WiFi via Time Capsule. I want the device to hit my computer first, so it will fall back on local/virtual hosts</edit>

In the interim, I'm using the Simulator.

Last edited by davidbjames; 03-10-2011 at 08:00 AM. Reason: Better explanation of my situation
davidbjames is offline   Reply With Quote
Old 03-10-2011, 12:46 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2011
Location: The Netherlands
Posts: 44
Hollance is on a distinguished road
Default

Both the device and the server need to be on the same network, such as your home WiFi network.

Figure out what the IP address of the server is (for example, open Terminal and type "ifconfig") and put that in the URL that the app uses.

You have to use the IP address because you can't use a domain name unless you run your own DNS on the local network.

You also cannot use "localhost" because that only works for software that runs on the same machine (such as the Simulator), not for an app that runs on the device.
Hollance is offline   Reply With Quote
Old 03-11-2011, 04:11 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 2
davidbjames is on a distinguished road
Default

Quote:
Originally Posted by Hollance View Post
Both the device and the server need to be on the same network, such as your home WiFi network.

Figure out what the IP address of the server is (for example, open Terminal and type "ifconfig") and put that in the URL that the app uses.

You have to use the IP address because you can't use a domain name unless you run your own DNS on the local network.

You also cannot use "localhost" because that only works for software that runs on the same machine (such as the Simulator), not for an app that runs on the device.
Thanks Hollance. I totally spaced it that the device localhost (or virtual host) would loop back on itself. DOH. However, I also tried getting the IP address via ifconfig and that did not work. Also, I would have assumed that I could use my *static* IP (which I have from my service provider) but that didn't work either, even with the Firewall turned off. Kept getting "cannot connect to server" errors.
davidbjames is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 404
18 members and 386 guests
Brandt, coolman, Domele, Droverson, Duncan C, fredidf, Free App Monster, givensur, iAppDeveloper, locombiano89, Mah6447, MasterX, Meoz, simplymuzik3, SLIC, stanny, stevenkik, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,646
Threads: 94,111
Posts: 402,864
Top Poster: BrianSlick (7,990)
Welcome to our newest member, locombiano89
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:56 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0