Unless you have some other medium you can rely on (e.g. some sort of back-end you can use to exchange information), you will need Service Discovery
.
I have already written a few answers regarding WifiP2p
and Service Discovery
, and I suggest you take a look at them first. The last one should probably interest you the most.
- Why is discovering peers for Android WifiDirect so unreliable
- Wi-fi P2P. Inform all peers available of some event
- Wifi P2P service discovery works intermittently
To answer your question about the difference between WifiP2p
and ServiceDiscovery
, let me use a small analogy:
Imagine you're at the airport, you've just landed in a foreign
country. You're leaving the duty-free zone and you see all the people
that are waiting for people who have landed at the airport just like
you did. You need to find your taxi driver. You know he should be
waiting for you with a small piece of paper with your name on it. You
can see many guys like that, every single one of them is holding a
piece of paper with a name on it. You need to read through many of
them until you find the one with yours. But you don't have to talk to
all those people. You will talk only to your taxi driver, and you will
probably tell much more than just your name.
Now let me explain... Every single person holding a piece of paper represents a Broadcasted Service
. Every broadcasted service
can carry a small piece of information (a person name). The space for the information is very limited (you can't write much on the paper), and is "relatively permanent" (it takes a bit to change it). When you were searching for the right person, you were performing a Service Discovery
. You did not have to talk to all those people to read the names on those pieces of papers - you didn't have to connect to them (WiFiP2p-wise). When you found the one you were interested in, you talked to the man - you established a WiFiP2p connection. Now you can talk to him as much as you want - you can pass as much data as you want through the connection.