Multithreaded server-client application where multiple clients can send text and files via server
The project aims to help students to develop the idea of how client-server applications run and communicate. It's a simple implementation of server-client architecture that aims to simulate a classroom using TCP-IP protocol. Where students are able to join a server within the same port that the server uses, send texts to each other, ask/answer questions, and send/receive files.
- The whole implementation runs under TCP/IP protocol and on
localhost
. - Server supports multi-clients up to 30. This can be modified via
MAX_CLIENT_NUM
inutil.h
. - Server supports database functionality with SQLite3. Check out the Prerequisities.
- Server takes time for timeout. During the inactivity of 10 minutes, the server shuts itself. This can be modified via
TIMEOUT
inutil.h
. - The packet size is 1 kilobyte. This can be modified via
BUFF_SIZE
inutil.h
. - Each client supports multithreading for receiving and sending packets simultaneously.
- Students can send texts to each other through the server. This can also be mentioned as broadcasting.
- Students can ask, answer, and list all questions with defined commands. Check out the Usage.
- Students can transfer and list files through the server with defined commands. Check out the Usage.
- Students can list all current users on the server. The server keeps a list of active users in the database.
Important
The project was written/tested on Ubuntu/Linux. Some of the libraries are only compatible with Unix-like operating systems. Therefore, it does not run on Windows.
To install from the command line:
sudo apt install sqlite3
To verify the installation, check the software’s version:
sqlite3 --version
Or you can check the official Downloads page to install the source code.
Warning
The whole project runs on localhost
and has not been tested on distinct machines.
Trying to run the server and clients on different machines can cause fatal errors and crash the program entirely.
Warning
./bin
, ./bin/local
and ./bin/remote
folders are crucial for the project functionality
especially for the database and file transfer functions.
Do not modify, edit, or delete bin
and its sub-folders.
To install and build the project:
git clone https://github.com/CheesyFrappe/multithreaded-tcp-ip-chat-server.git
cd multithreaded-tcp-ip-chat-server/src
make
Run server on bin directory:
cd bin
./server
Run client(s) on bin directory:
cd bin
./client
There are several defined commands for the utilities. Each of the commands is described below:
- use
help
to list all command descriptions during the session. - use
quit
to exit from the application. - use
ASK
to ask a question.
ASK who is the first king of Portugal?
- use
ANSWER
to answer a question.
ANSWER it is Afonso I
- use
LISTQUESTIONS
to list all questions.
LISTQUESTIONS
(1) who is the first king of Portugal?
Afonso I
ENDQUESTIONS
- use
PUTFILE
to upload a file to the server frombin/local
folder.
PUTFILE 1.jpeg
[+]Uploaded ./local/1.jpeg 111817
- use
GETFILE
to download a file from the server tobin/local
folder.
GETFILE 1.jpeg
[+]FILE ./local/1.jpeg 111817
- use
LISTFILES
to list all files held by the server.
LISTFILES
(1) 1.jpeg
(2) operating_systems.pdf
ENDFILES
- use
LISTUSERS
to list all active users on the server.
LISTUSERS
(1) emir
(2) miguel
ENDUSERS