Aleks G
Aleks G

Reputation: 57306

iPhone simulator - connect to host computer

I am working on an iphone app that would (when completed) communicated with a back-end server over the internet. While I'm doing the development, I'm often in a situation with no internet connection (read 'long flights'). I have a web server running on my local mac, which has a full copy of the live web site. Theoretically, I should be able to connect from the iphone simulator to a web server running on the host machine - but how? Note that I don't have an external connection, therefore all of the mac IP interfaces are in the "disconnected" state (moreover, they are turned off - saves the battery).

What addresses would I need to use from the simulator? Is there some sort of a bridge interface between the host mac and the sim?

Many thanks.

Upvotes: 2

Views: 5452

Answers (1)

Jason Coco
Jason Coco

Reputation: 78343

If you're running in the simulator, connect to 127.0.0.1 -- that is the address of your local machine (also known as the loopback address). It will be configured and routed properly even if your normal network interfaces are down or disabled. Please note, however, that since this address is always the local machine, this will not work if you are running the app on a device (as the device will attempt to connect to itself and it will have no instance of your server running).

Upvotes: 7

Related Questions