NSD-related Android devices, how to send messages using sockets (Client-Client)?

I recently established a P2P connection in my application on several devices using this guide: http://developer.android.com/training/connect-devices-wirelessly/nsd.html

So, now I can find other devices on my network that launch my application. Now I want to send messages between clients. There may be 1.2 or more clients, but messages will only arrive 1 client at a time, more like a PING request, but with some text.

I read about sockets, and it seems like this is the way to go (will also communicate with iOS devices in the near future). But .. In all the examples and tutorials, I found that in the client group there is a server through which all messages pass. I just want to send a message from client to client.

I basically want:

  • list of all devices / clients on my network where my application is running, DONE! (Does IpAdress, port, etc. For everyone).
  • click one client and send message / message

Any hints or examples to look at? Should all client devices have a "server"?

Regards, Kristoffer

+4
source share

Source: https://habr.com/ru/post/1537918/


All Articles