building packets to send

Started by
2 comments, last by save yourself 19 years, 7 months ago
I have a setup in which there is a client (done in VB.net) connection to a main server (done in c++). A lot of the data that I need to send between the two are numbers between 0-255, so I just need one byte to represent each. Now instead of sending "123" which takes three characters, I can just send the byte value for 123. My question is, in VB.net, HOW can I turn this number into its single byte value and then add it to a string (or char array) to send over the network? The Chr and ChrW functions are a start... but I can only get those to work for 1-127. I believe after that it is trying to use a double byte character set which is NOT what I want. I also have a problem with 0 since it is the NULL terminator for a string... Any ideas on how I can convert 0-255 to a single byte then add it to the packet array?
Advertisement
Sounds like you're looking for the Convert class:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemconvertclasstopic.asp


Ryan
--Visit the Game Programming Wiki!
The BinaryWriter class may be what you're looking for here.
BinaryWriter did the trick, much thanks!

This topic is closed to new replies.

Advertisement