views:

681

answers:

1

For the current Android application I'm working on, I'm looking to create a tcp connection between the user device, and another Android device based on the phone number instead of the IP address. IE the user would open your contacts list, and be able to create a tcp connection to a contact using the same application as you.

I seem to remember seeing a socket that would take a phone number instead of an IP a while ago in the Android API, but now I can't find it. Am I just missing something, or was I mistaken in what I saw in the first place? If I am mistaken, does anyone know of way to create a tcp connection to a user based solely on their phone number?

+4  A: 

As neat as this would be, I think you were mistaken.

If the both parties have your application installed, you could write a service to periodically ping a central server with the phone's information and it's IP address (implicitly). This would be similar to how many dynamic DNS applications work.

That being said, mobile phones don't make good servers. The connection goes up and down, the IP address changes frequently, and the phone might end up on a WiFi network that has NAT.

It's much better to have both phones work through a reliable intermediary server, which would store and forward requests between devices.

Trevor Johns