A Tcp Server-Client aplication that provides functionality of sending files one-by-one from client to server, where they are processed via thread-safe system.
Server accepts multiple clients and provides a multithreaded processor.
Maximum number of threads and some other parameters can be preconfigured at the start of the server.
First, clone repo and cd in it via
git clone https://github.com/RoundRonin/TCP_Server_Client.git
cd TCP_Server_Client
To build this app use (at the root directory):
make build
If you want to rebuild the app use:
make rebuild
To clean up all the building use:
make clean
Building process also generates symlinks to the executables at the project's root, so you don't need to manage them.
After building the app you can start the server and specify some parameters.
To start the server use (at the root of the project):
./Tcp_Server
after running this command you will get a prompt of its usage:
Usage: ./Tcp_Server <configFile>
or: ./Tcp_Server -t <maxThreads> -p <port> -s <maxFileSize> -f <savePath>
As stated in the usage prompt, you can either supply a config file
Config is a Json file that supplies parameters. You can supply only paramets you want to change. Config file structure:
parameter | description | default |
---|---|---|
maxThreads | maximum amount of simultaneous threads that can process client's requests | 4 |
port | port of the server | 1234 |
maxFileSize | maximum size of file that the server will process, defined in kilobytes (KB). Server will reject every attempt to send a bigger file | 8096 |
savePath | location to safe file | ./Output |
Config example:
{
"maxThreads": 10,
"maxFileSize": 10000,
"savePath": "~/TcpServerFiles"
}
or use flags. You don't have to supply all the flags, it is sufficent to send only ones representing the values you want to redefine, then for other settings hardcoded defaults (defined at server's main.cpp) will be provided. Flag description:
flag | description | default |
---|---|---|
-t | maximum amount of simultaneous threads that can process client's requests | 4 |
-p | port of the server | 1234 |
-s | maximum size of file that the server will process, defined in kilobytes (KB). Server will reject every attempt to send a bigger file | 8096 |
-f | location to safe file | ./Output |
To send a file use (at the root of the project):
./Tcp_Client
Client's prompt is
Usage: ./Tcp_Client <filename> -i <ip_address> -p <port>
Filename should be supplied at all times. Flag rules are the same as with the server. You can provide any amount of flags, defaults are hardcoded (in client's main.cpp). Flag description:
flag | description | default |
---|---|---|
-i | ip address of the server | 127.0.0.1 |
-p | server port | 1234 |