As a spin off to this Stack Overflow question I want to archieve the same except for a couple of tweaks.
I want to connect to a host, send a binary file, line by lin
You can achieve it in two steps:
1) You need to start nc with a named pipe (fifo) as its input:
mkfifo /tmp/fifoIn; cat /tmp/fifoIn | nc localhost 2222 &
2) Send your data from file input.txt, line by line with 2 sec delay:
cat input.txt | while read line; do echo $line; sleep 2; done > /tmp/fifoIn
I've tested it with this "server" (I'm using openbsd netcat syntax):
nc -l localhost 2222