Skip to content

A TCP-based file transfer server built with Asio for asynchronous programming in C++, enabling directory browsing, file upload/download, and management over a TCP connection.

Notifications You must be signed in to change notification settings

Ioannis-Markos-Angelidakis/simple_cpp_cnc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

cpp23-filesystem-asio

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.

Features

  • 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

Functionality

  • 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.

Command Handling

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.

Technologies Used

  • 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

Compilation

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

Usage

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.

About

A TCP-based file transfer server built with Asio for asynchronous programming in C++, enabling directory browsing, file upload/download, and management over a TCP connection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published