Q:

Integer to Byte() array troubles

I'm trying to transmit data through the stream in Visual Basic .NET
I try the next:
Client:
tcpclnt = New TcpClient()
tcpclnt.Connect("127.0.0.115", 40000)
clientstream = tcpclnt.GetStream()

 Dim I As Integer
 Dim msg() As Byte
 For I = 1 To 1000
     msg = BitConverter.GetBytes(I) ' HERE IS THE PROBLEM
     clientstream.Write(msg, 0, msg.Length)
 Next

Server:
Public Shared bytes(1024) As Byte
Public Shared data As String = Nothing

Server = New TcpListener(IPAddress.Any, 40000)
Server.Start()
' ... some server routine

Dim serverstream As NetworkStream = myClient.GetStream()
Dim i As Int32
i = serverstream.Read(bytes, 0, bytes.Length)
data = System.Text.Encoding.ASCII.GetString(bytes, 0, i)
Invoke(Sub() TextBox3.Text = "Received: " + data)

The problem is: to get data from stream it have to be Byte() type. So to put data to stream it also have to be in Byte(). But I want to transmit integers (1000 for example). It converts in 4 bytes and when server reads it he takes four different symbols, not the number 1000!
Instead of 1000 I got two spaces.

A:

Thank you for the perfect answer, @xanatos.
I find one more way and use it, so I want to post it too.
I used this way:
 For I = 1 To 1000
        msg = Encoding.UTF8.GetBytes(Convert.ToString(I))
        clientstream.Write(msg, 0, msg.Length)
 Next

I suppose your solution is better in the way of controlling packages and I will use it for transmitting numeric data, but for my current case I used my solution.

