Pynosaur

Modern CLI tools with better UX

View the Project on GitHub pynosaur/pynosaur

← Back

sock

Pure Python socket communication tool for sending and receiving messages and files over TCP.

Reimagines netcat/telnet for the Pynosaur ecosystem.

Features

Installation

pget install sock

Or from source:

git clone https://github.com/pynosaur/sock.git
cd sock
python app/main.py --help

Usage

Receive (rec)

Listen on a port and receive messages or files:

sock rec 8080

Save received files to a directory:

sock rec 8080 -d ~/Downloads

Send (sen)

Send a message:

sock sen 192.168.1.10 8080 -m "hello"

Send a file:

sock sen 192.168.1.10 8080 -f document.txt

Full Duplex (mult)

Both sides can send text and files interactively.

Listen side:

sock mult -l 8080

Connect side:

sock mult 192.168.1.10 8080

Interactive commands inside mult:

> hello                    (send text)
/file notes.txt            (send a file)
/ping                      (ping remote)
/quit                      (close connection)

Network Utilities

sock info                  # Show local IP, public IP, gateway
sock test 8080             # Test if port can be bound

Examples

Local testing

# Terminal 1
sock rec 9000

# Terminal 2
sock sen localhost 9000 -m "hello from terminal 2"

File transfer over LAN

# Computer A (192.168.1.10)
sock rec 9000 -d ~/received

# Computer B
sock sen 192.168.1.10 9000 -f report.pdf

Interactive chat

# Terminal 1
sock mult -l 8080

# Terminal 2
sock mult localhost 8080

Protocol

sock uses a simple binary framing protocol over TCP:

[4 bytes: payload length (network byte order)]
[JSON header]\n[binary payload]

Packet types:

Type Purpose
msg Text message
file File transfer (header includes name and size)
ping Ping
pong Pong

Security

This is an educational tool with no encryption and no authentication.

Requirements

License

MIT