PDA

View Full Version : TCP/IP server in Iphone




forrestxu
Aug 5, 2008, 03:27 PM
Hi

I want to creat TCP/IP server in Iphone so that I can remotely control it by PC.

Is it possible?

Thanks,
Forrest



Cromulent
Aug 5, 2008, 03:49 PM
Hi

I want to creat TCP/IP server in Iphone so that I can remotely control it by PC.

Is it possible?

Thanks,
Forrest

I think you probably need to understand what it is you want to do first. TCP stands for Transmission Control Protocol and just controls how data is sent between computers. IP just stands for Internet Protocol which controls data transfer over the internet.

Neither offers anything like remote control. You are probably thinking of something like VNC.

keehun
Aug 5, 2008, 07:44 PM
Well, unless you have developer certificate, you won't be able to use any app you make on your actual iPhone.

1. If you did have the Developer Certificate, then you wouldn't be asking such a question

2. If someone was to make it, Apple would almost certainly never approve it for App Store.

keehun

forrestxu
Aug 6, 2008, 10:00 AM
Hi Cromulent and keehun,

Thank you for your help.

I have created TCP/IP server in simulator. I can control the simulator by the other coumputer.

My question is why "Apple would almost certainly never approve it for App Store?"

Thanks,
Forrest

Cromulent
Aug 6, 2008, 10:08 AM
I have created TCP/IP server in simulator. I can control the simulator by the other coumputer.

When you say control, what do you mean exactly? TCP/IP has absolutely nothing to do with controlling devices. It is a data transfer protocol that all other internet and most network based protocols are based on such as FTP, POP3, IMAP, NNTP, HTTP and so on.

firewood
Aug 6, 2008, 10:48 AM
Does the iPhone OS have a firewall that would block incoming TCP/IP connections? If not, then it might possibly be acceptable to use the SDK to build a server which stays completely within the app sandbox and only runs when it's in the foreground. But IANAL.

forrestxu
Aug 6, 2008, 10:50 AM
When you say control, what do you mean exactly? TCP/IP has absolutely nothing to do with controlling devices. It is a data transfer protocol that all other internet and most network based protocols are based on such as FTP, POP3, IMAP, NNTP, HTTP and so on.

Hi Cromulent,

Thank you for your reply.

The protocols you mentioned (FTP, POP3, IMAP, NNTP, HTTP) are application layer protocol and based on TCP/IP. I used normal socket code to create TCP/IP server in simulator, it works fine in simulator. And it can be built in device setting.
My colleague will test it to see if it can work in iphone.

Cheers
Forrest

SwampThingTom
Aug 6, 2008, 10:51 AM
If I understand what you are asking, you would like to have an App on the iPhone that opens up a server socket that a remote client can connect to and send commands to "control" the iPhone. Is that correct?

If so, you will have multiple problems.

1) Your phone doesn't have a static IP address. What's more, I believe the only way you can find an iPhone on a network is via Bonjour. Bonjour won't route across subnets so the phone you are trying to communicate with will have to be on the same subnet as the client. You *might* be able to use some sort of dynamic-IP routing service, like DynDNS, and have the App update its current IP address when it starts. But that process isn't instantaneous and phones are regularly switching networks so I don't think it's a practical solution.

2) Apps can't run in the background so the only time you'll be able to access it remotely is when the app is actively running. Although you haven't specified what you would like to be able to do remotely, it seems less useful to only be able to "control" the phone when the user is actively running your app.

3) The things you can control from your app will be very limited. You could have it dial a phone number, bring up a URL in Safari, open the Mail app, open the Maps app, and maybe send an SMS (not sure). If there are any other installed apps that have registered a URL, you can bring those up as well. But note that whenever any one of those happens, that app starts running and yours stops. So you could send one "command" but once it's done, the user would have to exit that app and start yours back up again to receive more "commands".

The bottom line is, for any useful definition of remote control that I can think of, you won't be able to do what I think you want. Of course, without knowing more about what you are trying to do, I can't be sure. If you can live with all of the above limitations, sure, you can "remotely control" an iPhone via TCP/IP.

forrestxu
Aug 6, 2008, 10:55 AM
Hi SwampThingTom,

Thank you very much!
You really sovle my question. You understand correctly!

Regards,
Forrest

If I understand what you are asking, you would like to have an App on the iPhone that opens up a server socket that a remote client can connect to and send commands to "control" the iPhone. Is that correct?

If so, you will have multiple problems.

1) Your phone doesn't have a static IP address. What's more, I believe the only way you can find an iPhone on a network is via Bonjour. Bonjour won't route across subnets so the phone you are trying to communicate with will have to be on the same subnet as the client. You *might* be able to use some sort of dynamic-IP routing service, like DynDNS, and have the App update its current IP address when it starts. But that process isn't instantaneous and phones are regularly switching networks so I don't think it's a practical solution.

2) Apps can't run in the background so the only time you'll be able to access it remotely is when the app is actively running. Although you haven't specified what you would like to be able to do remotely, it seems less useful to only be able to "control" the phone when the user is actively running your app.

3) The things you can control from your app will be very limited. You could have it dial a phone number, bring up a URL in Safari, open the Mail app, open the Maps app, and maybe send an SMS (not sure). If there are any other installed apps that have registered a URL, you can bring those up as well. But note that whenever any one of those happens, that app starts running and yours stops. So you could send one "command" but once it's done, the user would have to exit that app and start yours back up again to receive more "commands".

The bottom line is, for any useful definition of remote control that I can think of, you won't be able to do what I think you want. Of course, without knowing more about what you are trying to do, I can't be sure. If you can live with all of the above limitations, sure, you can "remotely control" an iPhone via TCP/IP.

Cromulent
Aug 6, 2008, 11:02 AM
The protocols you mentioned (FTP, POP3, IMAP, NNTP, HTTP) are application layer protocol and based on TCP/IP. I used normal socket code to create TCP/IP server in simulator, it works fine in simulator. And it can be built in device setting.
My colleague will test it to see if it can work in iphone.

Did you read my post? I stated the above protocols were built on top of TCP/IP.

Your use of the term TCP/IP server was confusing.

forrestxu
Aug 6, 2008, 11:08 AM
Did you read my post? I stated the above protocols were built on top of TCP/IP.

Your use of the term TCP/IP server was confusing.

Hi Cromulent,

Yes! I read your post. But TCP/IP server is vry popular. see

http://www.codeproject.com/KB/IP/tcpserverall.aspx

Regards,
Forrest

Cromulent
Aug 6, 2008, 11:37 AM
Hi Cromulent,

Yes! I read your post. But TCP/IP server is vry popular. see

http://www.codeproject.com/KB/IP/tcpserverall.aspx

Regards,
Forrest

I am well aware of what TCP/IP is. I would not have described it in the words that you have though, hence the confusion.