Reputation: 23
On an Android device, I want to create a tcp communication on a local network with a device that I know only the mac address (no the ip). There is a way to start the communication with only the mac address or, alternatively, to find directly the ip associated without scan all network looking for the device? Thank you very much
Upvotes: 2
Views: 1823
Reputation: 6857
To deliver ip address of your server to a client you can send broadcast UDP packet from server. The flow could look like this:
Server
opens TCP port and waits for TCP clients
.Server
sends broadcast UDP packet with specific data ( something which says that this packet is from your server
)client
in the same network it receives the packet. The client
reads data, checks that the packet is from your server
. This packet also has ip address of your server
.client
knows ip address and port, it connects through TCP to your server
.Server
accepts new client
. Connection is done.Here is sample of how UDP packet could be sent and received: https://stackoverflow.com/a/25520279/798165
Upvotes: 2