One possibility is to carefully arrange file descriptors manually, so that fds 0 and 1/2 go to the socket. Check out dup2(2).
But that's not probably what you want, or sensible.
But that's not probably what you want, or sensible.
rl_{in,out}stream. You can use fdopen to get a stdio stream from a fd (socket for example). This can be problematic if not done correctly (buffering & stuff). Official documentation has more info on all this.
You can also fork+dup2+pipe/pty and use stdin/out on the forked process.