views:

93

answers:

3

Hello, I am trying to get a simple sockets program working on the Ipad. To do this I am using the CFStreamCreatePairWithSocketToHost command.

It works fine on the simulator. The problem is that it does not work on the iPad (I checked connectivity issues using the iPad's safari, and everything seems fine).

What I want to do is have the iPad open a connection to a PC. The reason I used CFStreamCreatePairWithSocketToHost was that I found a simple 10 line sample program which does this.

My questions:

1 - Does CFStreamCreatePairWithSocketToHost work on the iPad

2 - Can anyone direct me to a simple sample for ipad socket communications (I tried apple dev, and google. No sample that I found could be considered simple (less than 50 lines of code...))

Update: Also tried sockets and NSHost, both withAddress and withName. The results were the same: works perfectly inside the simulator, but does not work on the iPad.

A: 

I would suggest to use the socket-wrapper AsyncSocket. The download comes with a sample project.

edit
the most recent version can be found here

vikingosegundo
A: 

The low level APIs don't turn on the cellular radios. Use a very high level API to connect, then after the radios are turned on, disconnect if necessary, and (re)connect via BSD sockets.

An HTTP request to a server near the same destination IP would probably be sufficient.

hotpaw2
A: 

Found the problem... There was a "rouge" proxy problem in my organization, which was forwarding the saffari, but not my program (even thoughthe safati was not on an http port).

Solved, and thanks for your help.

eshalev