- Create named pipe
pi@raspberrypi ~ $ mkfifo thepipe
- Start a netcat listener which outputs to the pipe (redirected STDOUT)
pi@raspberrypi ~ $ nc -l -p 4444 >thepipe
- Run the program in gdb with stdin redirected from pipe.
pi@raspberrypi ~ $ gdb -q ./program
r <thepipe
- Connect to the listener (using netcat)
ubuntu@ubuntu $ nc 127.0.0.1 4444
- Whatever is sent to netcat as input becomes the input of the program. The output of the program will display in gdb and isn't redirected and can be done similarly if needed.