I'll try to be as precise as possible.
I have a TCP Server, a TCP Client, both of them sends bytes to each others and store them into an Array upon arrival.
This Array contains the string i sent from the Server + about 8100 characters represented by 0 in bytes.
Then, the Array is converted into a string and when you output it, it shows a normal string.
But this string is fact 8100 characters long so if i try using it with a Select Case, it never works even tho the string outputted is exactly the same.
What i wanna do is ignore all the bytes equal to 0 and store everything else into an array but, another problem arise.
You can't create an empty array in Visual Basic, you can either specify it's size or add items to it right away and, i don't know how long the array is gonna be.
Also, if i make a new array equals to 1000 just to be safe, the same problem arise but now, my string is equal to 1000+ characters.
How can i fix this? I've spent 6 hours trying different things, i even asked on stackoverflow but nobody knows what to do.
If somebody can help, I'll be forever grateful.
TCP Server :
TCP Client :
I have a TCP Server, a TCP Client, both of them sends bytes to each others and store them into an Array upon arrival.
This Array contains the string i sent from the Server + about 8100 characters represented by 0 in bytes.
Then, the Array is converted into a string and when you output it, it shows a normal string.
But this string is fact 8100 characters long so if i try using it with a Select Case, it never works even tho the string outputted is exactly the same.
What i wanna do is ignore all the bytes equal to 0 and store everything else into an array but, another problem arise.
You can't create an empty array in Visual Basic, you can either specify it's size or add items to it right away and, i don't know how long the array is gonna be.
Also, if i make a new array equals to 1000 just to be safe, the same problem arise but now, my string is equal to 1000+ characters.
How can i fix this? I've spent 6 hours trying different things, i even asked on stackoverflow but nobody knows what to do.
If somebody can help, I'll be forever grateful.
TCP Server :
vb Code:
Try Dim bytes() As Byte = System.Text.Encoding.ASCII.GetBytes(requestedAction) _TCPServer.Send(bytes) Catch ex As Exception End Try
TCP Client :
vb Code:
If _TCPStream.DataAvailable Then Dim rcvdbytes(_TCPClient.ReceiveBufferSize) As Byte _TCPStream.Read(rcvdbytes, 0, CInt(_TCPClient.ReceiveBufferSize)) Dim request As String = System.Text.Encoding.ASCII.GetString(rcvdbytes) Execute_Action(request) 'Info sent to Select Case End If