Though I've go through the document here, it still doesn't make sense to me what it is:
Data is read from the pipe as a stream of messages. This mode can be only used if PIPE_TYPE_MESSAGE is also specified.
Though I've go through the document here, it still doesn't make sense to me what it is:
Data is read from the pipe as a stream of messages. This mode can be only used if PIPE_TYPE_MESSAGE is also specified.
In BYTE mode, you are the one that needs to figure out the separation of the data so that it can be decoded at the receiving end. In MESSAGE mode, the API will do this for you. When you read the message on the other side you will have the whole block of data (the message).
In both cases, you will still need some header data to wrap your message/data to know what it is if you are mixing data types sent through the pipe.
EDIT: The documentation points to a very clear example of Client/Server using this API and the MESSAGE mode between both.
http://msdn.microsoft.com/en-us/library/aa365592%28v=VS.85%29.aspx
http://msdn.microsoft.com/en-us/library/aa365588%28v=VS.85%29.aspx
The difference between PIPE_TYPE_BYTE
and PIPE_TYPE_MESSAGE
type mode are explained on the http://msdn.microsoft.com/en-us/library/aa365605.aspx:
Type Mode
The type mode of a pipe determines how data is written to a named pipe. Data can be transmitted through a named pipe as either a stream of bytes or as a stream of messages. The pipe server specifies the pipe type when calling CreateNamedPipe to create an instance of a named pipe. The type modes must be the same for all instances of a pipe.
To create a byte-type pipe, specify PIPE_TYPE_BYTE or use the default value. The data is written to the pipe as a stream of bytes, and the system does not differentiate between the bytes written in different write operations.
To create a message-type pipe, specify PIPE_TYPE_MESSAGE. The system treats the bytes written in each write operation to the pipe as a message unit. The system always performs write operations on message-type pipes as if write-through mode were enabled.
If you want to write a data stream with respect of pipes you should use PIPE_TYPE_BYTE
type mode. Then you can write any data in the pipe buffer with respect of WriteFile
and read there on the other side with respect of ReadFile
. How exactly the data will be send is not important for you. The data from some WriteFile
operation can be transfered as one data block.
If you use PIPE_TYPE_MESSAGE
type mode every write operation follows to the data transfer, because the writing in the pipe will be interpret as a sending of the message. There are a special function TransactNamedPipe
which allow you to write a message to and read a message from the specified named pipe into a single network operation.