views:

235

answers:

3

As a communications method is TCP best way to get lots of data through to multiple android devices from another android device over 3g? Also are there recommended ports to use for 3g data transfer?

I want to rule out using a web service intermediary as I want this app to be decentralised if possible.

Cheers, James

A: 

If you have data that cannot miss parts you must use TCP. If you have a data that can lose some parts like a video/voice chat you can use UDP.

3G uses the same network layer as any other network type, so you are free to use any ports you like.

Pentium10
+1  A: 

As a communications method is TCP best way to get lots of data through to multiple android devices from another android device over 3g?

Given your "no Web service" limitation, 3G may be useless to you. Many mobile carriers use NAT and related technologies, so there is no guaranteed way to make a direct socket connection between two devices. The same holds true for WiFi -- many WiFi routers use NAT, handing out private IP addresses, precluding direct socket connections without modifying one of the routers.

CommonsWare
hmmm, okay if a web service is the only option what is the minimum I could get away with? Simple storage system using UDP? Error checking can be done by the applications and signed.Also is it possible on layer 2 OSI to broadcast to ports or do raw sockets also get the same treatment?
James Birchall
@James Birchall: "okay if a web service is the only option what is the minimum I could get away with?" That is completely dependent on what protocols you are looking to use and largely independent of Android. There is a fair amount written about NAT traversal for P2P systems. However, I am not expert in this area. You might want to take a look at JXTA, for example: http://en.wikipedia.org/wiki/JXTA
CommonsWare
thank you CommonsWare, will post here if I get a solution.
James Birchall
A: 

Some 3G networks might offer multicast which is the least effort for any server since it sends the message once regardless of the number of subscribers. Otherwise each listening device is going to have to open a unique socket to the server and the server is going to have to send each in turn the message. Depending on the nature of the message it might be possible to use UDP or TCP. That all rests on whether the message requires acknowledgement, whether it is volatile, whether there are many messages or just a few etc.

Something like JMS or a message bus would typically handle all this for you. I don't know if there is a port of JMS to android (e.g. OpenJMS) but its worth investigating.

locka