On Mon, 24 Mar 2008 12:45:58 -0700, Kenny D <kennydevries@hotmail.com
wrote:
Quote:
Blocking Peek(): I can place a break point after the call to peek.
The break point never gets hit until data is in the pipe waiting to be
read.
The next statement after the call to Peek() only executes when Peek()
returns something other than -1. Are you sure that it's not just that
Peek() keeps returning -1?
And I reiterate: given that the docs say that Peek() will return -1 if no
data is available, under what condition would Peek() block? Conversely,
feel free to describe a condition under which Peek() would return -1.
Quote:
I will code up the console applications. They won't be ready for a
couple of hours as I have to step out. This will help out a lot
because I have not had anyone else try this on their machines.
>
Please keep an eye on this thread. I really need to get to the bottom
of this.
For better or worse, your question is likely to get exactly the same
attention anyone else's does. If you have an urgent situation, you may
want to consider paid developer support from Microsoft. You'll find that
many of us are reasonably responsive, but there's not likely to be any
point in expressing your urgency. And at worst, it implies that we are
are your beck and call, which is surely not the implication you intended..
You're welcome. :)
Quote:
K
>
Code for the other method...
I see at least four problems in that code, at least three of which I
believe are significant.
Specifically:
Quote:
>
Int32 BytesRead = 0;
do
{
byte[] Buffer = new byte[ReadBufferSize];
BytesRead = InputStream.Read(Buffer, 0, ReadBufferSize);
>
if (BytesRead 0)
{
MsgText.Append(Encoding.BigEndianUnicode.GetString (Buffer));
}
At the very least, you have a problem any time that a Unicode character
gets split in two during network transmission. You also aren't taking
into account the actual count of BytesRead when you convert the buffer to
a string, but since the buffer is zero-filled and you allocate it anew
each time (inefficient, but workable) I think this isn't as likely to
cause a problem.
Quote:
>
string Text = MsgText.ToString();
Int32 Pos = Text.IndexOf(EOM);
>
if (Pos 0)
{
Pos += EOM.Length;
MsgText.Length = Pos;
>
break;
}
What happens when you receive more than one message in a single read?
You're just discarding whatever text was read after the current message's
EOM.
Quote:
>
} while (InputStream.DataAvailable);
Like Peek(), the DataAvailable property doesn't tell you anything about
the future condition of the stream. So if you stop here, then as soon as
the stream gets temporarily interrupted you incorrectly will detect that
as the end of the message. Of course, if the actual EOM text hasn't
arrived yet, your code breaks.
Pete