Exploring server-client networking concepts using modern C++23 features.
Implementing a synchronous single-threaded server and client application.
Utilizing C++ std::filesystem
for file operations and standalone ASIO library for TCP/IP communication, and pattern matching with mpark/patterns.
This project is a TCP-based file transfer server which allows users to browse directories, upload, download, and manage files over a TCP connection.
- Browse the current directory and list its contents
- Change directories, including handling environment variables for paths
- Download and upload files
- Send entire directories with file transfer support
curr_path()
- Sends the current directory path to the connected client.directory_listing()
- Lists the files and directories in the current directory and sends the information to the client.change_directory()
- Changes the server's working directory based on the command from the client, supporting environment variables in the path.send_file()
- Sends a requested file to the client, ensuring the file exists before transferring.receive_file()
- Receives a file from the client and saves it to the server, with support for file replacement.send_directory()
- Sends an entire directory recursively to the client, including file contents and directory structure.
The server listens for and processes commands sent by the client:
- cd <path> - Change the server's current directory to the specified path.
- ls - List the files and directories in the current directory.
- pwd - Show the server's current directory path.
- download <file> - Request the server to send a file.
- upload <file> - Send a file to the server.
- get <directory> - Download an entire directory from the server.
- Asio - C++ library for networking and asynchronous programming
- C++23 - Utilizes modern C++23 features
- Filesystem - C++ standard library for file and directory manipulation
- mpark/patterns - Pattern matching library for cleaner command handling
To compile the server, you can use the following command:
clang++ -Wall -Wextra -Wpedantic -Wconversion -fsanitize=address server.cpp -o server -std=c++23 -lws2_32
Once the server is running, it listens on port 12345
for incoming TCP connections. Clients can send commands to interact with the server, browse directories, and transfer files.