문제

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