Question

I've got a problem.

I have a process, let's say it is a client, and a process called server. Client and server communicate with each other by the same queue. Let's say a client sends a message to the server (request), so the server processes it and should send message back to client a confirmation or a failure. Let's say that confirmation has a long type = 1500101, and failure has long type = 1500102.

Is it possible (using msgrcv in C) to wait for only those two types of messages (client) ? If not, what is the best way to do such a mechanism?

Was it helpful?

Solution

No, you can't receive on multiple messages types. It's either all or just a single type or all except a single type.

What you can do is call msgrcv with the IPC_NOWAIT flag twice, once for each type.

OTHER TIPS

Client and server are communicate with each other by the same queue.

I suggest that client and server have separate individual queues. Then server can receive all messages coming to it on its queue (using msgtype as 0). It can switch on the basis of msgtype of a message received and do the necessary action.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top