This repository contains a simple chat application implemented in Python that demonstrates the use of both TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) for network communication. The application includes separate server and client scripts for each protocol, allowing users to explore the differences in how TCP and UDP handle data transmission.
- Python 3.x
- Access to a command-line interface
- You can use the implemented run options to select to run UDP or TCP Clients or Servers. There is also an option to run a Server with 3 Clients in one click.
Note: If you are going to run Servers and Clients via Bash or one by one with the launcher, in order to have a flawless experience, ALWAYS RUN THE SERVER FIRST!
- Start the TCP Server:
- Navigate to the
tcp
directory. - Run the server script using Python:
python3 server.py
- Navigate to the
- Run the TCP Client:
- Open a new command-line interface window.
- Navigate to the
tcp
directory. - Start the client script:
python3 client.py
- Start the UDP Server:
- Navigate to the
udp
directory. - Run the server script:
python3 server.py
- Navigate to the
- Run the UDP Client:
- Open a new command-line interface window.
- Navigate to the
udp
directory. - Start the client script:
python3 client.py
- Broadcast a message:
- Using a client, type a message without any of the commands below and it will be broadcasted.
- Send a Private Message:
- Using a client, type:
/pm [nickname] [message]
- Using a client, type:
- Send a .txt content to another client:
- Using a client, type:
/sendtxt [nickname] [filename]
- Note: The file has to be into the tcp/ or udp/ folder depending on which you are using. There is already a testfile(TCP/UDP).txt to facilitate the usage.
- Using a client, type:
- Send a .txt file to another client:
- Using a client, type:
/sendfile [nickname] [filename]
- Notes: The file has to be into the tcp/ or udp/ folder depending on which you are using. There is already some files: testfile(TCP/UDP).txt, 1200.txt (1200 bytes file), 2000.txt (2000 bytes file) to facilitate the usage.
- The file will be sent to a folder path named
inbox/{nickname}
.
- Using a client, type:
- Exit with a client:
- Using a client, type:
/exit
- Using a client, type:
-
TCP is a connection-oriented protocol, ensuring that all packets arrive at their destination in the same order they were sent. This is ideal for applications where accuracy is critical, such as web browsing and email.
-
UDP is a connectionless protocol, which does not guarantee packet order or delivery. This makes UDP faster and more efficient for applications where speed is more important than precision, such as streaming audio and video.
This chat application provides a basic framework for understanding and experimenting with TCP and UDP protocols. You can extend the functionality or adapt the code for different network communication scenarios.