Character 255 behaves oddly when sent over a network stream

Character 255 behaves oddly when sent over a network stream

Post by Justin Lyo » Wed, 12 Feb 2003 05:07:51



Did character 255 become some sort of reserved character for networking in
Dot Net?  When I try to send it via a network stream, it gets replaced with
several other characters.  Do I need to do something special to send just a
single character 255?
 
 
 

Character 255 behaves oddly when sent over a network stream

Post by news.microsoft.co » Wed, 12 Feb 2003 07:31:30


If you're trying to write to a stream, be aware that when you write a char
of value 255, the text encoding of the stream is used, that's why you get
several packets.

You should write it as bytes, not chars (chars in .net are not always 1 byte
long, they may be 2 or more)...

Sbastien Lambla


Quote:> Did character 255 become some sort of reserved character for networking in
> Dot Net?  When I try to send it via a network stream, it gets replaced
with
> several other characters.  Do I need to do something special to send just
a
> single character 255?


 
 
 

Character 255 behaves oddly when sent over a network stream

Post by Justin Lyo » Wed, 12 Feb 2003 07:41:34


I had tried sending a char of value 255 both as a byte and a char with no
luck.

I have since discovered that sending two char 255 back to back as bytes does
work.  However two char 255 as a string does not.  I don't really know why
that is.  I did discover that char 255 is reserved for the telnet protocol,
but I have sucessfully used it before dotnet.

Now I guess I just need a good way to convert a string to an array of bytes.
VB doesn't seem to be able to make the cast directly, and I'm sure looping
is inefficient.  Maybe I'll need to inbed some C.


Quote:> If you're trying to write to a stream, be aware that when you write a char
> of value 255, the text encoding of the stream is used, that's why you get
> several packets.

> You should write it as bytes, not chars (chars in .net are not always 1
byte
> long, they may be 2 or more)...

> Sbastien Lambla