This project is a work-in-progress implementation of a basic client-server application using TCP/IP communication in C++. The client can send messages to the server, which processes them and sends back responses.
Client:
- Connect to server via IP address and port.
- Send text messages to the server.
- Receive responses from the server.
- Automatic reconnection on connection loss.
Server:
- Handle multiple client connections simultaneously.
- Parse incoming messages and count the occurrence of different letters.
- Provide the number of current connections upon request.
- Enable communication between clients through the server.
- Offer shutdown functionality.
- Programming Language: C++
- Build System: CMake and Make
- Unit Testing: Google Test
- Integration Testing: Python
- Code Coverage: gcovr
- Documentation: Doxygen
- Linux operating system or MacOS
- C++ compiler
- CMake and Make
- Google Test
- Python3 and pytest
Building with Make:
note: all commands should be executed from the project root directory
- Clone the repository.
- Navigate to the project directory.
- Build the project:
make
Running the Server:
- Execute the server binary with the desired port:
build/server <port> [silent]
- The
silent
option disables server console output.
- The
Running the Client:
- In a separate terminal, run the client binary:
build/client <server_ip> <server_port>
Running Tests:
- Build and run automatic tests with
make test
. Code is also statically analyzed withcppcheck
thenmake test
is used - Check code coverage with
make coverage
- Check memory leaks with
make leaks
- Build and run manual tests with
make debug_run
Generating Documentation:
- Generate the documentation with
make docs
- The documentation will be generated in the
docs
directory. - Open the
index.html
file in thedocs/html
directory to view the documentation.
Installing:
- Because the project is a work-in-progress, it is not yet available for installation. However, you can still use it by building and running the project.
Basic Client-Server Communication:
- Start the server on port 8080:
build/server 8080
- In another terminal, connect a client:
build/client 127.0.0.1 8080
- Type a message in the client, such as "Hello, world!".
- The server will respond with the count of each letter:
H |1
e |1
l |3
o |2
, |1
|1
w |1
r |1
d |1
! |1
Client-to-Client Communication:
- Connect two clients to the server.
- In one client, send a message to the other client using the format:
send <client_id> message
- For example:
send <client_2> Hi there!
- For example:
- The other client will receive the message:
client_1: Hi there!
- The client can also send a message to itself using the command:
send <self> message
.
- Do not forget to use the
<
and>
symbols to enclose the client ID.
Server Commands:
show list
: Display a list of connected clients with their IDs.show number
: Show the number of currently connected clients.shutdown
: Shut down the server gracefully.
- Implement command line editing and commands history for the client.
- Add support for file transfer between clients.
- Enhance security features with encryption and authentication.
- Explore other communication protocols like UDP.
Contributions are welcome! Please feel free to submit pull requests or open issues for bug reports and feature suggestions.