A multi-threaded client-server file sharing application built with Python and Tkinter. This application allows multiple clients to connect to a centralized server for uploading, downloading, listing, and deleting files with a graphical user interface.
- Multi-threaded architecture supporting concurrent client connections
- Secure file storage with user-based ownership
- Persistent file registry that survives server restarts
- Real-time logging and monitoring through GUI console
- File upload/download with progress tracking
- Client notification system for file downloads
- User authentication with unique username enforcement
- Intuitive graphical user interface
- File upload with drag-and-drop support
- File download capabilities
- Server file listing and browsing
- File deletion (owner permissions required)
- Real-time notifications for file activity
- Connection status monitoring
The application uses a dual-socket architecture:
- Primary Socket: Command handling and communication protocol
- Secondary Socket: High-speed file transfer operations
All data transfer follows a standardized packet structure:
- 4-byte length prefix (big-endian) followed by actual data
- Command codes for different operations (UPLOAD, DOWNLOAD, LIST, DELETE, NOTIFY)
- Acknowledgment system (OK/NOK) for operation confirmation
file-server-408/
├── server/
│ ├── server_backend.py # Core server logic and networking
│ ├── server_gui.py # Server GUI implementation
│ └── parser.py # Protocol parsing utilities
├── client/
│ ├── client_backend.py # Client networking and logic
│ ├── client_gui.py # Client GUI implementation
│ ├── parser.py # Protocol parsing utilities
│ └── test_files/ # Sample test files
└── README.md
- Python 3.6 or higher
- Tkinter (included with most Python installations)
- Standard library modules:
socket,threading,os,re,time
- Clone the repository:
git clone <repository-url>
cd file-server-408- No additional dependencies required - uses Python standard library only.
- Navigate to the server directory:
cd server- Run the server GUI:
python server_gui.py-
Configure server settings:
- IP Address: Enter the server IP (e.g.,
localhostor127.0.0.1) - Port: Choose a port number (e.g.,
8080) - Directory: Select where uploaded files will be stored
- IP Address: Enter the server IP (e.g.,
-
Click "Start" to begin accepting client connections
- Navigate to the client directory:
cd client- Run the client GUI:
python client_gui.py-
Enter connection details:
- IP Address: Server IP address
- Port: Server port number
- User Name: Unique username for this session
-
Click "Connect" to establish connection
- Click "Upload File" button
- Select file from file dialog
- File will be uploaded and stored with format:
username_filename
- Click "Retrieve Server Data" to refresh file list
- Select a file from the list
- Click "Download" to save file locally
- Select a file you own from the list
- Click "Delete" to remove file from server
- Only file owners can delete their files
- Click "Retrieve Server Data" to see all available files
- Files are displayed with owner information
- Server files are stored in the configured directory
- Files are prefixed with the owner's username:
username_filename.ext - File registry is maintained in
permanent-file-registryfor persistence - Server state is preserved across restarts
DOWNLOAD = 1: Request file downloadUPLOAD = 2: Request file uploadLIST = 3: Request file listingDELETE = 4: Request file deletionNOTIFY = 5: Server notification to clients
OK = 10: Operation successfulNOK = 11: Operation failed
- Client sends command on primary socket
- Server acknowledges and prepares secondary socket
- File data transfers on secondary socket (port + 1)
- Secondary socket closes after transfer completion
- Username uniqueness enforcement
- File ownership verification for delete operations
- Connection authentication and validation
- Isolated file storage per user
- Connection failure recovery
- File operation error reporting
- Server disconnection detection
- Invalid file access prevention
Server Backend (server/server_backend.py)
Serverclass handles all networking and file operations- Multi-threaded client connection management
- Persistent file registry system
Client Backend (client/client_backend.py)
Clientclass manages server communication- Asynchronous command handling
- File transfer operations
Protocol Parser (server/parser.py)
- Standardized packet sending/receiving functions
- Command and acknowledgment handling
- Binary data serialization
-
"Username already taken"
- Choose a different username
- Wait for previous session to timeout
-
"Connection failed"
- Verify server is running
- Check IP address and port settings
- Ensure firewall allows connections
-
"File upload failed"
- Check file permissions
- Verify sufficient disk space on server
- Ensure file is not locked by another application
-
"Cannot delete file"
- Only file owners can delete their files
- Refresh file list to see current ownership
- Default setup uses consecutive ports (e.g., 8080 for commands, 8081 for data)
- Ensure both ports are available and not blocked by firewall
This project is built for educational purposes.