I want server to send some message to client and client to ACK it. I have been given this assignment. Can I do it using a single message queue in C linux or I need to create two??
Thanks :)
I want server to send some message to client and client to ACK it. I have been given this assignment. Can I do it using a single message queue in C linux or I need to create two??
Thanks :)
Yes, it is possible to do this with sysV messages queues, which from looking at your previous questions, you are using. You can use the msgtype
field embedded in the message format to specify what kind of message it is and the appropriate receiving process has to specify that msgtype in its msgrcv
call and process messages of that type.
So, for example, server can write msgtype = 1 and client can ack msgtype 2.
Note that this requires you to really think out your messaging scheme - read the msgrcv
docs carefully so you understand the options for how messages can be read - and why you are doing it. If you don't do it right it won't scale well - not in performance but in programming complexity - and it will be easy to get yourself in a situation where your programs are chasing their own tails.
Whether this is smarter than just using two queues I will leave for you to decide.
Note that you really can't do this with POSIX message queues.
No, You have to use two message queues