0

How do I create a client-server socket communication?

Share:

In this example you’ll see how to create a client-server socket communication. The example below consist of two main classes, the ServerSocketExample and the ClientSocketExample. The server application listen to port 7777 at the localhost. When we send a message from the client application the server receive the message and send a reply to the client application.

The communication in this example using the TCP socket, it means that there is a fixed connection line between the client application and the server application.

To test the application you need to start the server application. Each time you run the client application it will send a message “Hello There…” and in turns the server reply with a message “Hi…”.

Filed in: Java Networking

Leave a Reply

Submit Comment

© 2014 Java Examples - Developed with