none
Pipe.IsMessageComplete is incorrect RRS feed

  • Question

  • Hello,

    I have pipe client and pipe server from PipeStream and NamedPipeClientStream,NamedPipeServerStream. I do check the Pipe.IsMessageComplete==true to get completely transferred data, however, I see that i get it =true even the data is not fully. 

    stream.ReadMode = PipeTransmissionMode.Message 

    Does anyone know the reason?

    Please advise.

    • Moved by Bob Shen Thursday, August 16, 2012 4:57 AM (From:Visual C# General)
    Wednesday, August 15, 2012 5:30 AM

Answers

All replies

  • you can try to use EndRead() property of the message, whether it is same as the length of the total message in bytes.

    regards

    joon

    Wednesday, August 15, 2012 9:29 AM
  • Hi Cplusp,

    Welcome to the MSDN Forum.

    This property is related to the most recent read or endread operation. If it doesn't read more data, its value is True.

    So you can also check the read data length.

    Best regards,


    Mike Feng
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, August 16, 2012 7:10 AM
    Moderator
  • I think you are partly correct in use of IsMessageComplete, but I also use "if (numBytes > 0)"

    Here is how I read from a NamedPipeServerStream

    do 
    { 
      numBytes = pipeServer.Read(bytes, 0, BufferSize); 
      if (numBytes > 0) 
      { 
    	...
      } 
    } while (numBytes > 0 && !pipeServer.IsMessageComplete); 
    For more detail, see my PipeServer project (C# and VB) in the code sample at this link:

    Interprocess Communication Using .NET 3.5 Named Pipes IO


    Dan Randolph - My Code Samples List

    Thursday, August 16, 2012 5:32 PM