Maybe you could fork your main process into two:
The father will read user input and send it through the socket.
The son will receive data and display it on the screen.
If I am right, you can't use the same socket for both son and father, as the file descriptor (the socket) is not shared among them. Each process (father and son) will open its own connection. You could also use a thread, which I think that would make your job a lot easier.
Anyway, it is an idea.