[Mono-dev] Problem in Mono's implementation of System.IO.StreamReader?

Thiago Padilha tpadilha84 at gmail.com
Mon Jul 12 08:21:00 EDT 2010


Actually, I worked arround this by wrapping the networkstream inside a
bufferedstream then used a binaryreader to advance line by line
without much performance loss. Then I just passed the bufferedstream
which was on the right position(even though it probably consumed the
entire networkstream).

On Sun, Jul 11, 2010 at 4:42 AM, Roman Procopie
<procopie.roman at gmail.com> wrote:
> Hi
>
> I had same problem, in similar circumstances. It seems that you need to pass
> the actual StreamReader to the further use of the stream.
>
> Regards
> Roman
>
> On 8 July 2010 22:22, Thiago Padilha <tpadilha84 at gmail.com> wrote:
>>
>>  Hi,
>>
>>  I'm using StreamReader to read some text from a network stream that
>> will contain a two part message : the first part(the one I'm reading)
>> contains some headers in plain text, the second part may contain any
>> kind of data.
>>  It doesnt matter the data in the second part of the message, I
>> intend to pass the underlying Stream to another code that will
>> correctly deserialize it. The problem is that the StreamReader decodes
>> a lot of text on my first call to ReadLine() (much more than one
>> line). The result is that the NetworkStream advances more than it
>> should, and I cant deserialize the second part of the message.
>>  Is this intended behavior? I can easily work arround this by
>> buffering the second part of the message and wrapping a MemoryStream
>> arround it, but I'd rather pass the NetworkStream directly.
>>  Also, sometimes I intend to close the network connection and discard
>> the second part depending on the headers I find.(And since the reader
>> will already have buffered it, the data will have to wait for garbage
>> collection).
>>
>>  Thanks.
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>


More information about the Mono-devel-list mailing list