Coders Packet

Client-Server communication using Python socket module for file transferring

By Nediff Amala Nixon

A GUI implementation of Client-Server communication to transfer files using the socket module of Python 3.0

A GUI implementation of basic Client-Server communication to transfer files where the user can send or receive files with a peer-to-peer connection using the socket module of Python 3.0.

The purpose of this project is to share confidential files within an organization, friends or families without using a third-party application.

This GUI interface provides basic features such as browse the file to send, notify the user so that the user is aware of the file transfer status and the receiver has the ability to accept or decline the incoming connection.

Working of the application:

1. The application is divided into two major parts, Client and Server.

2. The Server is responsible for accepting the incoming connections from the clients whereas the Client is responsible for connection with the Server and send the desired file.

3. The working of the server is divided into two threads using the threading module in Python 3.0.

4. Thread 1 is responsible for creating the socket instance, bind to a port, listen and accept the incoming connections.

5. Since the Server can accept more than one connection,  the application stores the connection details of the previously accepted connections in a separate list.

6. Thread 2 is responsible for choosing a connection from the list based on user preference and then connecting to that connection to receive files.

7. These two threads make sure that the server can accept and receive files parallelly from the client.

8. The responsibility of the client is to connect to the server and wait for the connection success acknowledgment so that the client can send the required file to the server.

9. Once the file is successfully sent, the client receives a message that the file is successfully received from the client.

10. The self.__host variable under the client function has to be set to the IP address of the server.

10. I have set the client and server to close the connection as soon as the file is received to avoid possible malicious attacks on the socket.

Python 3.0 modules used:

1. PySimpleGUI module (using pip install)

This module will be used to design the GUI of the application.

The PySimpleGUI cookbook:

2. Socket module (in-built module)

This module is used for socket programming.

3. Threading module (in-built module)

This module is used to implement the two threads of the server.

Other modules that were used to facilitate these above modules are sys, os and queue module.

Run the FILE file to start the application.

Download Complete Code


No comments yet