This project provides a simple TCP file transfer server and client using Winsock for Windows and POSIX socket APIs for Unix-like systems. The server sends requested files to the client upon request.
- Server (
server.cpp
): Listens for incoming client connections, handles file requests, and sends requested files to the client. - Client (
client.cpp
): Connects to the server, requests files by name, and saves the received files locally.
- Windows: Visual Studio or another C++ compiler that supports Winsock.
- POSIX Systems: A POSIX-compliant system (Linux, macOS) with a C++ compiler.
- C++17 or later: The code uses features from C++17, such as
std::filesystem
andstd::atomic
, which are not available in earlier versions of C++.
To build the server and client applications, use the provided server.cpp
and client.cpp
source files. Ensure that you link against the ws2_32.lib
library on Windows.
- Open Visual Studio.
- Create a new project or open an existing one.
- Add
server.cpp
to the project for the server application andclient.cpp
for the client application. - Configure the project to link against
ws2_32.lib
(typically found under project properties -> Linker -> Input). - Build the project.
- Open a terminal.
- Navigate to the directory containing
server.cpp
andclient.cpp
. - Compile the source files using a C++ compiler. For example:
g++ -o server server.cpp g++ -o client client.cpp