Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I want to start a little project, where I want to connect several of my devices. Some are Android mobile devices, others are desktop devices like a PC or laptop. Furthermore I want keep the project as generic as possible. Means I want to share it, so other people can use it.

By connecting I mean send messages between them. My problem is, that I'am not sure what technology or architecture to use, and hope to get some advice from you. (I think this question is more about software architecture then gorilla vs. shark)

I have considered several approaches already. I looked at Google's Cloud Messaging, but that seems not to fit my requirements, where several users can register to send independent messages. It looks more like, sending from one master to several devices.

The next thing I thought about was something lile VLC did with its Android remote app, where the desktop application hosts something like a server to which the mobile app must connect. This seems to be limited to LAN and only fits to about 80% of my use cases.

Is there another approach which does not require something like a server who is aware of all clients, which has to seperate the user's devices and route the messages?

share|improve this question

1 Answer 1

You can use ZeroConf (a.k.a. Bonjour) to discover other devices on a local network and create an ad hoc network between them. If you want to be able to connect devices across larger networks, though, you're going to need a server with a fixed address so that all parties have some well-known address that they can connect to. Most devices (laptops, tablets, phones, etc.) don't have a fixed address, so they're often hard to find. Further, they're often behind firewalls which make them impossible to connect to even if you do know where to find them. Instead, each device needs to initiate the connection. Two devices obviously can't both initiate the same connection, but having them both connect to some server that relays messages between them solves the problem.

You also need to consider usability. You don't want to run background software that's constantly listening for connections on a mobile device simply because listening means that the WiFi radio has to be running, and keeping that radio running all the time is a quick way to kill your battery. You don't have that problem with a stationary server.

share|improve this answer
    
Do you have any experience, so you can recomend a server setup? I wanted to keep costs low, and therefore avoid purchasing a server.. –  Angelo.Hannes Jan 20 '13 at 20:51
    
You surely don't need to buy a server -- there are hundreds of options for Internet hosting. Some options are free for light use (Amazon's EC2, Google App Engine), most others are more traditional pay services. You can get more bandwidth than you probably need, unlimited disk space, e-mail accounts, popular content management systems, and all sorts of other features for $3 or $4 per month. –  William Shakespeare Jan 20 '13 at 21:10
    
Thanks, for your hint about GAE. I looked into it, and it seems very promising. But I still didn't figured out how to notify the clients, of an event that occured in the server? I think for Android devices GCM comes to mind. But is it appropriate for a client like an Laptop or PC to pull with an 500ms rate? –  Angelo.Hannes Jan 25 '13 at 14:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.