This Is basic example to show client server architecture. Things you should remember is to establish connection between client and server socket. Once the sockets are established and connection is made you can communicate.
In the communication normally sender sends a string other side. So recipient should be capable of reading the content and understand what to perform. So that it is very useful to send the string bind with special header (command)where recipient can understand the command and process.
Below example shows you key features how to communicate within server and client
Source code is available at following link: