Skip to content
Back to skills

P2p Lan Transfer

ASecurity

Peer to peer file transfer patterns for local networks

  • 2 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 10, 2026
ai-agentspythonrustgonodesecurity

Works with

  • cli

Security analysis

A100/100

Scanned September 10, 2026

npx -y skills add LoopyLuci/Skills --skill p2p-lan-transfer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of P2p Lan Transfer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for P2p Lan Transfer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/loopyluci-p2p-lan-transfer/badge)](https://www.skillsdirectory.com/skills/loopyluci-p2p-lan-transfer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: p2p-lan-transfer
description: "Peer to peer file transfer patterns for local networks"
---

# P2P LAN File Transfer

Patterns and approaches for direct device-to-device file transfer over a local network. No cloud, no internet required.

## When to Use

| Scenario | Best Approach |
|----------|---------------|
| Same WiFi network | Direct TCP over LAN |
| Mobile hotspot | Direct TCP (both on hotspot) |
| Ethernet + WiFi | Direct TCP (same subnet) |
| Different subnets | UPnP / NAT traversal or relay |
| No network | WiFi Direct or USB tethering |

## Architecture Options

### 1. Direct TCP (Simplest)

```
Device A (server) ←→ TCP connection ←→ Device B (client)
```

- One device acts as TCP server
- Other connects directly
- Fastest possible speed (full LAN bandwidth)
- No dependencies beyond Python stdlib

### 2. WebSocket

```
Device A ←→ WebSocket ←→ Device B
```

- Built-in browser support
- Framing protocol built in
- Slightly more overhead than raw TCP

### 3. WebRTC

```
Device A ←→ WebRTC ←→ Device B
```

- NAT traversal built in
- Browser-compatible
- Works across some subnets
- Complex setup

## Recommended: Direct TCP

For Python-to-Python transfers on the same LAN, direct TCP is fastest and simplest:

```python
# Server
import asyncio

async def handle_client(reader, writer):
    # Receive file metadata
    data = await reader.readexactly(4)
    # ... receive file

async def main():
    server = await asyncio.start_server(handle_client, "0.0.0.0", 8877)
    await server.serve_forever()

# Client
async def send_file(host, port, filepath):
    reader, writer = await asyncio.open_connection(host, port)
    # Send file
    writer.write(data)
    await writer.drain()
```

## Discovery Methods

| Method | Library | Requires |
|--------|---------|----------|
| mDNS | `zeroconf` | Same network, UDP 5353 open |
| Broadcast ping | UDP broadcast | Same subnet |
| Manual IP | User input | User knows the IP |
| QR code | `qrcode` | One device has a screen |

## Speed Optimization

| Technique | Gain |
|-----------|------|
| Chunk size 1MB | Reduces syscall overhead |
| Parallel streams (2-4) | 2-4x on high-latency links |
| TCP_NODELAY | Reduces Nagle algorithm delay |
| Large socket buffers | 256KB+ for fast networks |
| Async I/O | Non-blocking, efficient |

## Security

- **Same network** = same trust domain (typically)
- **Add pairing/PIN** to prevent unauthorized access
- **TLS** for encryption over LAN (self-signed certs)
- **Rate limit** connection attempts to prevent scanning

## Pitfalls

- **Windows Firewall** blocks inbound connections by default
- **Mobile networks** isolate devices (carrier NAT)
- **Company WiFi** may have client isolation (AP isolation)
- **VPNs** route traffic externally, defeating LAN transfer

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.