Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By gdsports
#75170 There are non-coding options on Linux for reading data from a socket. netcat (nc) can listen on a TCP or UDP port and send the incoming data to stdout.

The following listens on TCP port 8266 and sends incoming data to stdout.

Code: Select all$ nc -k -l 8266


To save the data to a file, redirect stdout to a file.

Code: Select all$ nc -k -l 8266 >mydata.txt


To see the data and save it a a file at the same time, use tee.

Code: Select all$ 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.
User avatar
By McChubby007
#75171
gdsports wrote:There are non-coding options on Linux for reading data from a socket. netcat (nc) can listen on a TCP or UDP port and send the incoming data to stdout.

The following listens on TCP port 8266 and sends incoming data to stdout.

Code: Select all$ nc -k -l 8266


To save the data to a file, redirect stdout to a file.

Code: Select all$ nc -k -l 8266 >mydata.txt


To see the data and save it a a file at the same time, use tee.

Code: Select all$ 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.


Wow, really! That is a great and simple solution - I *do* like simple. It's ironic, I have worked full-time on UNIX, AIX and then Linux since 1993 and yet I have little network expertise due to the specialised nature of my work, and I never knew these commands, so I'm really appreciative.