This project implements a simple key-value store using both TCP and UDP communication protocols.
The system consists of a client and server for each protocol, allowing users to interact with the key-value store
by performing get
, put
, and delete
operations.
The TCP Client communicates with the TCP Server and the UDP Client communicates with the UDP Server.
To start the UDP-based key-value store server, run the following command:
Navigate to src/server on a terminal
java ServerUDP.java <Port Number>
Example:
java ServerUDP.java 8080
To start the TCP-based key-value store server, run the following command:
java ServerTCP.java <Port Number>
Example:
java ServerTCP.java 8081
To start the UDP client and connect to a key-value store server, use the following command:
Navigate to src/client
java ClientUDP.java <HostName> <PortNumber>
Example:
java ClientUDP.java localhost 8080
To start the TCP client and connect to a key-value store server, use the following command:
java ClientTCP.java <HostName> <PortNumber>
Example:
java ClientTCP.java localhost 8081
Once the client connects to the server, it will prompt the user to choose an operation:
- get
<key>
: Retrieves the value associated with a given key. - put
<key> <value>
: Stores a key-value pair in the server. - delete
<key>
: Removes a key-value pair from the server. - exit: Terminates the client connection.
The server processes each request and returns the appropriate response to the client.
- Ensure that the server is running before starting the client.
- The server must listen on the specified port to accept connections.
- The system supports both TCP and UDP communication for flexibility.
- Use localhost as the host when running locally.