I created my own chat program: Server listens on a main fifo. Client starts, creates a client rfifo and registers client rfifo with server by sending data to main fifo. Server awaits user 2 to connect. Another client(user 2) creates another client rfifo and connects and registers it's own rfifo with server via main fifo. Server sees two users in chat. Server switches client rfifos so that when one user sends data to main fifo, the main fifo returns the data to the other client rfifo. Both users need to be in the same group(prevents the need for OTHER permissions) and all fifos are created in /tmp directory. Chat session takes place over terminal emulator.
1. I'd like to upgrade my chat program by implementing TCP sockets so that the users can access the server remotely. Basically, I'm looking for something to where the server can bind to a tcp port, or even bind a fifo to a tcp socket. Then the client connects to the server via tcp and then would be able to create a client rfifo in the /tmp directory as well as open the main fifo for write. I've done some research and I'm thinking it's rather difficult to implement in this particular way. I don't want to use SSH/Expect or NFS. I don't want to be transferring files to and from server. Is there a library or function that would be able to aid in this way? Where I'd connect to the server and be able to open/create a file in just /tmp directory on the server?
2. On this chat program, it does contain one ugly design flaw. It's designed for just 2 chat users. Basically for one user, it prints its prompt with the username and then the user types in whatever he likes. If the other user types something in and hits enter, the other user's prompt along with the text appears on the users interface. However, if just one user does all the talking, you see an ugly design unfold. Here's an example.
Code:
bob: hey
alice:
bob: i was there the other day
alice:
bob: i went and picked up two bottles
alice:
bob: paid 6 bux
So I'd like to have a separate framebuffers, one for the output and another for the input, like all modern chats. Any libs/functions I can take a look at that could help accomplish this? Later on I would like to use ncurses but for now just want to use basic terminal emulator.