Netcat is the solution when a simple network socket is required. The Netcat utility abstracts away all of the tedious parts of TCP sockets. Simply open a port and receive data or connect to an existing listener.

Below are several useful examples of using Netcat.

Use Netcat to serve on port 80 continuously.
(while true; do echo -e "HTTP/1.1 200 OK\n\n $(date)" | nc -l -p 80 -q 1; done) &

NetCat simple TCP listener on port 1337 where the local ip address is 192.168.1.13.
nc -l 192.168.1.13 1337
or on any available ip address:
nc -l -p 1337

Connect to existing TCP server sockets using Netcat. This could be a Netcat listener or some other TCP service. For this example, the service is hosted on ip address 192.168.1.13 and port number 1337.
nc 192.168.1.13 1337

Port scanning
nc -z -n -v 10.0.2.15 1-99999

Send and receive the contents of some text file over a TCP connection. First, start the Netcat listener and direct any received data to a text file. This must be started first, or the sender will receive errors.
nc -l 4444 > received_file.txt

Now the sender may send the file to the listener on 192.168.1.13 and send the contents of data.txt.
nc 192.168.1.13 4444 < data.txt

Voila