Set up the connection with address and port number. Listen to the response from client. Once the setup is finished and ServerSocket accept(), the control power is transferred to Socket.
The actual role for communication between client and server.
- Setup ServerSocket with port number.
- accept() returns a Socket
- Initiate a client Socket
- Use Socket.getOutputStream/getInputStream
Basic structure of client:
- Open a socket.
- Open an input stream and output stream to the socket.
- Read from and write to the stream according to the server’s protocol.
- Close the streams.
- Close the socket.