[Mono-list] TCPClient not normal bevaiour
andyhume32 at yahoo.co.uk
Tue Dec 4 18:38:12 EST 2007
You want to specify Encoding.ASCII in the StreamWriter ctor. Otherwise some arbitrary encoding will be used (Encoding.Default). And if it's UTF-8 then you'll get the Unicode BOM preamble first.
Note that in the original code the 'other' two StreamWriter instances are created and then immediately discarded -- after first reading a value that was available directly... Wierd. Do as Alan suggested but supply Encoding.ASCII as the second argument.
> -----Original Message-----
> From: mono-list-bounces at lists.ximian.com
> [mailto:mono-list-bounces at lists.ximian.com] On Behalf Of Phillip N.
> Sent: 04 December 2007 13:29
> To: Alan McGovern
> Cc: mono-list at lists.ximian.com
> Subject: Re: [Mono-list] TCPClient not normal bevaiour
> Hi alan,
> Thanks for your response.
> Actually, it think its bizarre too, but it the way a library
> im using does it. :)
> kangoroo at irc, sudgested it could be a encoding problem.
> And its true.. LANG=C does solve the thing.
> Anyway, is this a bug?
> El mar, 04-12-2007 a las 21:07 +0000, Alan McGovern escribió:
> > Attach a compilable testcase so the behavior can be
> checked. That'll
> > make it easier to spot the issue. The only thing i'd say is
> that the
> > way you've created the streamwriter is probably the most
> bizarre way
> > i've ever seen. It's identical to this:
> > StreamWriter writer = new StreamWriter(socket.GetStream());
> > except you're creating two additional streamwriters for
> some unknown
> > reason. The additional bytes could be a byte order mark.
> What happens
> > if you do a .Receive() in c#, do you get just the 5 bytes?
> > Alan.
> Phillip N. <pneumann at gmail.com>
> Mono-list maillist - Mono-list at lists.ximian.com
More information about the Mono-list