sockets - Best solution to communicate in Android -


i want create android app (my first one) friend. main part of app communicatioon between 2 devices. phone needs able send info phone b , vice versa. question "*what's best solution establish communication ?" ...

at moment trying sockets. 1 phone server , other 1 client , communicate. problem doesnt seem work client never reaches server (time out). may because ip address client enters router address ...

the other solution have intermediate web server communicates phones throught http. think may consume lot of internet connection. how can know ?

please choose best solution between these 2 or 1 if have idea.

edit : forget mention 2 devices not in same local network need communicate internet.

thanks. onyx

i can recommend 2 ways:

  1. the quickest way solve issue direct socket connection between devices. maybe doesn't work in case, because 1 of phones in local network. cannot access ip outside, cause of network adress translation. should not connect wifi , find out ip-adress of device. here more information: https://de.wikipedia.org/wiki/network_address_translation

maybe following tutorial helpful you. http://android-er.blogspot.co.at/2014/02/android-sercerclient-example-client.html

  1. depending on want achieve, can build rest-backend. should not use solution, if need high performance , fast communication. building rest-backend can recommend node.js , swagger, maybe should take @ technologies.

Comments