Domanda

This is a very basic question. Trying to write IPC mechanism using pipes. I have used a simple client and server example from msdn that tosses char messages to and fro. Now my requirement is that server keeps listening for the commands from the clients. On receiving a instruction from the client, server performs some action and gets back to client.

The example demonstrates how to read the stuff. But I need to trigger or a signal when something comes into my pipe, so that I can perform read operation that time and get out. Dedicating a single thread to keep reading looks inefficient. If i have 10 clients, 10 threads per client and 10 threads for reading is not good.

so, Is there a mechanism where I can get notification from the pipe that I got to read something?

È stato utile?

Soluzione

You can use IOCP on pipes. ReadFile, WriteFile, TransactNamedPipe, and ConnectNamedPipe API's can be used with pipe handles.

ReadFileEx and WriteFileEx can also be used with completion routines, (don't go near the hEvent synchro design), for pipe I/O.

See MSDN for fuller details.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top