Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pass string between two wifi direct connected user in android using wifi direct?

i have recently implement wifi direct into my project,my aim is pass string value between two wifidirect connected devices when some of my app condition satisfies.right now i have listed all peers and also made connection between the selected peer.now i need to pass String values to the connected devices..how can i pass string between two connected device. i have checked the [Wifi Direct chat][1]

[1]: https://github.com/life0fun/wifi-direct-chat project but it is very complicated.so any one suggest me any idea how can i pass the String values between two connected wifi device.(If code is needed i will post the code here)

like image 304
Ramz Avatar asked Nov 24 '22 21:11

Ramz


1 Answers

you can use socket to connect between two peers in the same network. for instance create a server socket on one of the peers on any port and then from the client side connect to that port on the other user . then you can use this socket connection to send strings, file whatever you want.

for starters i would recommend you employ the server socket on the group owner so it will be easier on your client side to get the ip of the peer(i.e group owner) using the groupOwnerAddress field provided by the api

refer to this -> http://www.oracle.com/technetwork/java/socket-140484.html

like image 173
user2458228 Avatar answered Nov 30 '22 23:11

user2458228