GeneticSmart
GeneticSmart

Reputation: 93

Communication between two Android phones using Wi-Fi network

I want communication between two Android phones, both the phones are connected to the same Wi-Fi network. Knowing the IP address I can directly use sockets to communicate with both the devices, but my question is, is it possible to get the IP address at the run time? Or is there some other way in which I can do this?

Upvotes: 3

Views: 7516

Answers (3)

hardartcore
hardartcore

Reputation: 17037

You can use jmDNS to achieve this. It's a really helpful library and once you detect the all devices connected to the same wifi you can get their ip and port so you can establish a connection. You can learn more about how to use it here.

Or you can use Android Wi-Fi Direct API which works only for API Level 14+. Here is more information about the API : Wifi-Direct.

Hope it is what you are looking for! : )

Upvotes: 6

roxX
roxX

Reputation: 156

You can use Google Android NSD service.

Check out http://developer.android.com/training/connect-devices-wirelessly/nsd.html

Upvotes: 1

XorOrNor
XorOrNor

Reputation: 8978

Assuming that both devices are in the same local network you could use/write kind of ip scanner (Check every single ip adress whether is alive and if it is try to connect).

Upvotes: 0

Related Questions