开发者

Any suggestion about writing a chat room C program in Linux using Pipes and Daemon Processes? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 8 years ago.

Improve this question

The requirement is to make a C/C++ program that is a chat room.

1, Both the client and server program need no GUI, use command line only. And they only need to run in the same machine, connected with pipes.

2, Use a FIFO queue in a Da开发者_如何学JAVAemon Process, and users can chat using the Daemon Process at the same time.

3, The Daemon Process refreshes the number of online users and print login/out messages to the clients.

4, Client requires a nick name on start and the server reject when the nick name conflicts.

.

It's supposed to adapt Processes, Daemon Processes, Pipes, Signals, I/O, Threads to make this program, as much as possible.

Now I'm not familiar with Processes in Linux. Can you show me an Example of operating processes for a chat room, or a simple frame that I can write the functions without worrying the processes.

And any other suggestions about writing this program is welcome!


Sounds like you are being asked to both design and write this program.

Your question sounds rather like you need to have a client-server architecture (which makes sense) and talks over a pipe (you could equally do the same thing with a socket so you might want to make this layer easy to swap out later)

So, you need one program that runs in the background once started ( a daemon ) that runs the service listening on a pipe for chat messages and also monitors /var/run/utmp to see who is logged into the machine.

The daemon could be written as a single-thread process and using select calls to monitor client and the utmp file but since you have the threads requirement you could make each of these two functions be threads, makes your program more complex and harder to debug but who am I to argue.

You need another program that a user can run to connect to the daemon via a pipe and that you can type messages into or print messages from the daemon. Again, this could be done single-threaded but you might want to split transmit and recieve into threads instead.


How about just using talk?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜