Sockets are created for client and server. The ServerSocket class is used for creating sockets for server. The Socket class is used for creating sockets for client side.
After creating the sockets, these sockets are utilized for both writing and writing data onto the streams. For writing data onto the output stream using client socket, the method getOutputStream() is sent as parameter to the designated output stream object, such as DataOutputStream. For reading data from the input stream using client socket, the method getInputStream() is sent as parameter to the designated inpout stream object, such as DataInputStream.
For placing data on the server socket, the method accept() is used. The result of accept() is assigned to the client socket.