Nices way ... Stream!
-
Is there a nices way than this:
System.IO.Stream stream = irdaClient.GetStream();
int msglength = System.Net.IPAddress.HostToNetworkOrder(textBox1.Text.Length);
byte[] length = new byte[4];
length[0] = (byte)((msglength >> 0 ) & 0x000000FF);
length[1] = (byte)((msglength >> 8 ) & 0x000000FF);
length[2] = (byte)((msglength >> 16) & 0x000000FF);
length[3] = (byte)((msglength >> 24) & 0x000000FF);stream.Write(length, 0, length.Length);
I think that the way with the
byte
array is not very nice! I think it's ugly X|! Thestream
is a IrDA connection! I have tried theStreamWriter
class, but that doesn't work! The Server-Application receives some wrong things! Daniel ;) --------------------------- Never change a running system! -
Is there a nices way than this:
System.IO.Stream stream = irdaClient.GetStream();
int msglength = System.Net.IPAddress.HostToNetworkOrder(textBox1.Text.Length);
byte[] length = new byte[4];
length[0] = (byte)((msglength >> 0 ) & 0x000000FF);
length[1] = (byte)((msglength >> 8 ) & 0x000000FF);
length[2] = (byte)((msglength >> 16) & 0x000000FF);
length[3] = (byte)((msglength >> 24) & 0x000000FF);stream.Write(length, 0, length.Length);
I think that the way with the
byte
array is not very nice! I think it's ugly X|! Thestream
is a IrDA connection! I have tried theStreamWriter
class, but that doesn't work! The Server-Application receives some wrong things! Daniel ;) --------------------------- Never change a running system!If all you are trying to do is put the bytes of the int into the stream, why not use a
BinaryWriter
? This class has many overloads for Write(). Hope this helps, Nathan --------------------------- Hmmm... what's a signature? -
If all you are trying to do is put the bytes of the int into the stream, why not use a
BinaryWriter
? This class has many overloads for Write(). Hope this helps, Nathan --------------------------- Hmmm... what's a signature?Thanks! I will try it! Daniel ;) --------------------------- Never change a running system!