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?

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top