A simple Java TCP socket implementation demonstrating client-server communication.
This project contains a basic TCP client-server application in Java. The server listens for incoming connections on port 5001, and the client connects to send and receive messages.
src/
├── client/
│ └── Client.java # TCP client implementation
└── server/
└── Server.java # TCP server implementation
- Java Development Kit (JDK) 8 or higher
javac -d out src/server/Server.java src/client/Client.javaIn one terminal, start the server:
java -cp out server.ServerIn another terminal, run the client:
java -cp out client.ClientServer Terminal:
Hello Server..!
Client Terminal:
Hello Client!
- The server creates a
ServerSocketon port 5001 and waits for a connection - The client establishes a
Socketconnection tolocalhost:5001 - The client sends a message: "Hello Server..!"
- The server receives and prints the message, then responds with: "Hello Client!"
- The client receives and prints the response
- Both connections are closed
This project is available for educational purposes.