Simple LAN file-transfer utility using UDP discovery and TCP file transfer.
Zender discovers peers on the local network (UDP broadcast), negotiates a TCP connection, and sends or receives files using a small, interactive console UI and native file/folder choosers.
src/xender.py— main implementation (discovery, connection, transfer, console UI).test/test_xender.py— interactive test/demo for sending/receiving sockets.
- Peer discovery (broadcast / scan).
- TCP-based file transfer with simple framing (filename length, filename, filesize, then file bytes).
- Console menu for scan/broadcast and send/receive flows.
- Cross-platform input handling (Windows
msvcrt, Unixselect) and Tkfiledialogfor choosing files/folders.
- Python 3.8+
- Optional:
netifacesfor better broadcast address detection (pip install netifaces). tkinter(usually included with Python on Windows/macOS; install system package on some Linux distributions).
- (Recommended) Create and activate a virtual environment:
python -m venv .venv
.\\.venv\\Scripts\\Activate.ps1 # Windows PowerShell
# or
.\\.venv\\Scripts\\activate.bat # Windows cmd
source .venv/bin/activate # Unix/macOS- (Optional) Install
netifaces:
pip install netifaces- Run the interactive Zender app:
python -m src.Zender
# or
python src/Zender.py- Main menu:
[1] Scanto look for nearby devices,[2] Broadcastto advertise and accept a connection,[3] Exit. - After connecting, choose
[1] Send filesto open a file dialog and send one or more files, or[2] Receive filesto pick a destination folder and receive incoming files. - On the console prompts, press
qto cancel scans or receives where supported. - The tool uses a simple framed protocol: command byte (0x01=file), 4-byte filename-length, filename, 8-byte filesize, file bytes.
- The included
test/test_xender.pyfile acts as an interactive demo to create a listening or connecting socket. Run it and follow on-screen prompts:
python -m pytest test/test_xender.py -qOr run two terminals manually:
- Terminal A (listener):
python -m src.xender # choose Broadcast and accept
- Terminal B (sender):
python -m src.xender # choose Scan and connect, then Send files
- The code falls back to the broadcast address
255.255.255.255whennetifacesis not available or no broadcast address is found. - On Windows, console key detection uses
msvcrt.kbhit(); on Unix it usesselectand reading from stdin. - The UI uses
tkinter.filedialogfor file/folder selection — when running headless or in CI, GUI dialogs will block or fail. - The current transfer protocol is intentionally simple and meant for local, trusted networks — it has no encryption or integrity verification.
PRs and issues welcome. If you add features (e.g., resume, checksums, GUI, encryption), include tests and a short usage example.
Provided for learning and experimentation.