Skip to content

nc

Netcat clone - Connect to or listen on sockets.

Synopsis

tofu nc <host> <port> [flags]
tofu nc -l <port> [flags]

Description

A netcat clone for TCP/UDP connections. Can act as a client connecting to a server, or as a server listening for connections.

Flags

Flag Short Description Default
--listen -l Listen mode for inbound connections false
--udp -u Use UDP instead of TCP false
--verbose -v Verbose mode false

Examples

Connect to a server:

tofu nc localhost 8080

Start a TCP server:

tofu nc -l 8080

Use UDP:

tofu nc -u localhost 5353

Simple chat between two terminals:

Terminal 1 (server):

tofu nc -l 9000

Terminal 2 (client):

tofu nc localhost 9000

Port scanner (connect test):

echo "" | tofu nc -v localhost 22

Send data to server:

echo "Hello, server!" | tofu nc localhost 8080

Receive data and save to file:

tofu nc -l 9000 > received.txt

Transfer a file:

Receiver:

tofu nc -l 9000 > file.txt

Sender:

tofu nc localhost 9000 < file.txt