Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Peer-to-Peer communication options

can anybody confirm what are the currently allowed methods for peer-to-peer communications within the Android framework? I need to transfer json strings and I'm currently using SMS which works ok but the problem is that the data also ends up as lots of text messages. I've read Reto Meier's first edition of Professional Android Application Development where he says that the data transfer options were not implemented due to security concerns.

Has this changed at all and how would you do peer-to-peer transfer of data?

like image 231
John J Smith Avatar asked Feb 18 '11 12:02

John J Smith


People also ask

What is an example of peer-to-peer communication?

P2P became widely known by computer users as they began sharing MP3s and other files over P2P networks. For example, Napster is an example of a P2P software application. After downloading and installing this program users were able to connect with other computers, search for songs, and download any of them freely.

What are the types of peer-to-peer network?

Within Peer-to-Peer file sharing networks there exist two distinct types. The first of these types is a “pure” peer-to peer network and the second is a “hybrid” Peer-to-Peer network.

What is peer-to-peer communication?

Peer-to-peer (P2P) is a decentralized communications model in which each party has the same capabilities and either party can initiate a communication session.

What are some examples of peer-to-peer applications?

Peer-to-peer (P2P) software allows “peers” (individual computer systems) to connect to each other over the internet to share files. Examples of mainstream P2P software programs include BitTorrent, Limewire, Ares and AresWarez, Kazaa, Azureus, DC++ and Morpheus.


3 Answers

Have you looked at Qualcomm's AllJoyn library? It is designed to work over Bluetooth or wifi, so may fit, though if you're connecting over 3G or wider range networks it won't work.

Given the variation and reliability of networks between two remote devices not on the same network, I'd question whether peer-to-peer is the best solution, and would venture to suggest considering using an application server in between, so you could then use Cloud to Device Messaging [deprecated] (perhaps in tandem with Google App Engine). i.e. to send a message the sender passes it to the server, and the server then passes it on to the recipient.

In theory all devices on the net have a unique IP address and can talk to each other, but it's rarely that simple as routers/firewalls are configured differently so you'd need to pay great attention to the ports you use, especially considering many inbound ports are blocked by default for security reasons.

like image 159
Ollie C Avatar answered Oct 17 '22 16:10

Ollie C


You can simply use UDP/TCP sockets. In a separate thread you set up the server-side listener socket and that's it. Of course your application has to be started first (or should run in the background all the time). Here's an example:

http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/

If you also need peer discovery that will make the thing more difficult.

like image 6
ldx Avatar answered Oct 17 '22 15:10

ldx


You should also take a look at peerdroid, an open source project available here. I've been looking in to peer communication options from the point of view of having a collection of federated devices (pre-paired, if you like, similar to Bluetooth pairing); this library looks like it may give you the foundation for what you are trying to do.

If you are on your own network (for example a home or office WiFi) then you should be able to query for other connected devices. If the network you are on is not under your control (the mobile network or a public wifi) then the network will have been configured to isolate each device from everything else. In this case you will have no choice but to put a server up to act as the man in the middle. That brings its own architectural compromises - every device has to regularly poll the server or keep a connection open - unless you use Google App Engine which supports push notifications over Google's own infrastructure.

like image 4
Phil Haigh Avatar answered Oct 17 '22 17:10

Phil Haigh