I don't understand how to properly setup a data transmission between two host with unstable ethernet connection.
This is my /simple/bash/script.sh
#!/bin/bash
while [ true ]; do
    cat /dev/virtual  | nc -v 192.168.1.1 5005 || echo "nc failed" && exit   
    sleep 5s
done
exit
If I manually start it and on the destination netcat isn't running it would say:
5005 (tcp) failed: Connection refused
But it would not exit.
I need it the other way:
- check netcatconnection is ok.
- then pipe cat /dev/virtual.
Is there a way to catch the netcat status and then if it is failed: connection refused restart the main bash script?

/dev/virtualvia netcat"?nc -v 192.168.1.1 5005 </dev/virtual