Use the netcat (nc) utility to perform a variety of tasks that are associated with TCP or UDP administration. You can use the command for both IPv4 and IPv6 networks.
You can perform the following tasks by using the netcat utility:
Open TCP connections
Send UDP packets
Listen on arbitrary TCP and UDP ports
Perform port scanning
Unlike the telnet command, where each error message is emitted separately to standard output, error messages that are generated by nc scripts are combined into one standard error, which is a more efficient method.
The netcat utility supports a new –M option, which enables you to specify per socket Service Level Agreement (SLA) properties. When you specify the appropriate properties along with the –M option, a MAC flow for the socket is created. For example, you might use the –M option as follows:
% nc -M maxbw=50M host.example.com 7777 % nc -l -M priority=high,inherit=on 2222
As shown in the previous example, the –M option can be used to specify a comma-separated list of name=value pairs of SLA properties.
Some installation methods do not install the netcat software package by default. Check whether the package is installed on your system as follows:
% pkg list network/netcat
If the package is not installed, install it as follows:
% pfexec pkg install pkg:/network/netcat
For more details, see the netcat(1) man page.