Skip to content

Pynosaur/sock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sock

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

Reimagines netcat/telnet for the Pynosaur ecosystem.

Features

  • Three modesrec (receive), sen (send), mult (full duplex)
  • Structured protocol — length-prefixed JSON headers + binary payload
  • File transfer — send and receive files with metadata
  • Network utilities — show IP info, test ports
  • Pure Python — stdlib only, no dependencies
  • Cross-platform — Linux, macOS, Windows

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.

  • Messages are sent in plaintext
  • Anyone who can reach the port can connect
  • Do not send sensitive data
  • Use on trusted networks

Requirements

  • Python 3.8+
  • No external dependencies

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors