The following listens on TCP port 8266 and sends incoming data to stdout.
$ nc -k -l 8266
To save the data to a file, redirect stdout to a file.
$ nc -k -l 8266 >mydata.txt
To see the data and save it a a file at the same time, use tee.
$ nc -k -l 8266 | tee mydata.txt
netcat's big brother is named socat. socat has far more options but I don't use it unless netcat can't get the job done.