How to establish connection in Java between devices within wifi range?
To establish a connection between two devices over a network (WiFi, cable, etc...) you need to write 2 pieces of software:
1) A server: which waits for connections
2) A client: which initiates a connection to the server
Once the client initiates a TCP connection then the devices are connected and you can send data and messages between them.
Here: Java Sockets
Here's a COMPLETE step by step tutorial on how to write a chat application: Client/Server Pair