NetCat (nc) is used to read and write to TCP and UDP network connections. It is an excellent tool for diagnosing network connectivity issues.
sudo apt-get install netcat
To listen to a specific port.
nc -l -p 8000
To write to a specific port
nc 127.0.0.1 8000 nc -v 127.0.0.1 8000