Search code examples
linuxtcpraspberry-pinetcatsocat

Sending a file continuously via netcat/socat


I want to send a file from one Raspberry Pi to another continuously (until they are powered off or something). I am sending data from one Pi to an AP, and forwarding that data from that AP to the other Pi. I am using the current code to send the file once (successfully):

Receiver: socat TCP-LISTEN:4242 /home/pi/Desktop/smth

Sender: socat TCP:hostname:4242 /home/pi/Desktop/zeroMega.dat

The file I'm sending (zeroMega.dat) is a randomly generated file, since I don't care about the data and just need to continuously send (loop) this file of 1 MB from one Pi to the other. How could I do this? I know I probably need to create a script to run this continuously, especially since I need this to run on startup. Any help would be appreciated. Thanks.


Solution

  • Put it inside an infinite loop:

    while true; do
      # whatever should be repeated forever
    done