NC(1)

NAME
nc (netcat) - use network sockets from the command line

SYNOPSIS
nc [-h]
[-ruvz] [-g gateway] [-G num] [-i secs] [-p port] [-o file] [-s addr] [-w secs] hostname port[s] [ports] ...
-l -p port [-nsuvwz] [-o file] [hostname] [port]

DESCRIPTION
nc allows you to use network sockets (tcp or udp) from the shell. I'm merely writing this man page so that i can "man nc" and find out what I've already forgotten.

For connecting to remote sites, it's usually only necessary to supply the host or ip address and port for the connection. For a listening on a socket, you must specify -l for listening, and -p port to specify the port on which you want to listen.

The options are as follows (with C and S indicating whether the option applies to the "client" or "server" roles in a tcp conversation):

-g gateway (C)
    Specifies a source routing hop for outbound connections.

-G num (C)
    Can be used to specify the source routing pointer in the ip header, presumably in order to forge unused previous steps in the source routed path.

-h  Minor help. Not very helpful, hence this man page.

-i secs (C)
    Delay interval for lines sent or ports scanned.

-l (S)
    Selects "listen" mode instead of connect mode so that people can connect to you.

-n (S)
    The -n option indicates that all ip addresses should be printed out instead of being looked up in the DNS.

-o file (CS)
    Sends a hex-dump of the traffic to the specified file.

-p local port number (CS)
    When connecting to a remote service, this is the port from which the connection will originate. When listening for remote clients, this specifies the local port on which to listen.

-r (C)
    Randomizes local source ports and addresses for outbound connections.

-s source address (CS)
    Specifies the local source address on which to listen, or from which to connect.

-u (CS)
    Selects UDP transport as opposed to TCP (the default).

-v (CS)
    Turns on verbosity. Use two (or more) for more verbosity.

-w secs (CS)
    This sets a timeout for connects or for final net reads.

-z (CS)
    Zero I/O mode. While mostly used for scanning, I'm sure you could find a way to use it for connect mode.

The nc utility exits after both input streams (stdin and the remote socket) have been closed. It doesn't do this very well, and relies rather heavily on the network layers at both ends for this, and as such, if microsoft products are used, it might not notice a close because microsoft sucks.

SEE ALSO
cat(1)

HISTORY
The nc utility, a "damn useful little backend utility" begun 950915 or thereabouts, as *Hobbit*'s first real stab at some sockets programming. Something that should have and indeed may have existed ten years ago, but never became a standard Unix utility. IMHO, nc could take its place right next to cat, cp, rm, mv, dd, ls, and all those other cryptic and Unix-like things.

BUGS
I don't know...I didn't write the damn thing. But there are probably a bunch. Go blame microsoft.