This is harder than you think.
You need to understand how terminals work - they use special escape sequences, for example. moving the cursor or color output. This is described using a terminfo file, which depends on the terminal. Ncurses translates API calls (for example, moving the cursor to a specific position) in such control sequences using terminfo.
Since the terminal (currently xterm , gnome-terminal , screen , tmux , etc.) is on the client side, you need to transfer the type of terminal from the client to the server. This is why, for example, ssh transfers this information from the ssh client to the server (try echo $TERM in your ssh session - it could be "linux" if you logged in via the console or "xterm" if you use X and Xterm). Also, you better have the appropriate terminfo available on the server.
Another puzzle piece is pseudo-terminals . Since relatively few people currently use serial terminals, their semantics are emulated, so applications and libraries (such as curses and her friends), originally developed for serial consoles, continue to work. This is achieved using pseudo-terminals - they look like pipes, the master and slave communicate, everything that is written on one side comes out on the other side. For the getty login getty , for example, you can simply use one side of the pty device and consider it a sequential line - your server program should process the other side of the pty, sending everything it receives from pty to your client via the network.
Terminal emulators also use ptys, type tty in your terminal and you will get something like /dev/pts/9 if you use a terminal emulator. On the other hand, pty is usually your shell, communicating with your terminal emulator through pty.
Your client program may more or less use standard input and standard output. If the information about your terminal is correct, the rest will be processed by your terminal emulator, just transfer everything you get from your server program to stdout and send everything you read from stdin to your server program.
I hope I have not left any important details. Good luck