Hi, I'm new to the forums so please forgive me if I post this in the wrong section.
Anyway I'm having a problem where if I convert a string to bytes then send it through TCP, on the other end it does not convert properly. The original string is present in the received bytes although there appears to be some hidden characters stopping me from using a select case. Rough code is below...
TCP Message Server Code:
Private Sub Listen()
Dim LST_PORT as int16 = 9292 'Port to listen on'
Dim TCP_LISTEN As TcpListener = New TcpListener(LST_PORT)
TCP_LISTEN.Start()
Try
Dim TCP_CLIENT As TcpClient = TCP_LISTEN.AcceptTcpClient
Dim NET_STREAM As NetworkStream = TCP_CLIENT.GetStream
'reading data'
Dim bytes(TCP_CLIENT.ReceiveBufferSize) As Byte
NET_STREAM.Read(bytes, 0, TCP_CLIENT.ReceiveBufferSize)
Dim RX_STRING As String = Encoding.ASCII.GetString(bytes)
Select Case RX_STRING.Trim.ToUpper
Case "1"
Console.Beep()
Case "SHUTDOWN"
Process.Start("shutdown", "-f -s -t 00")
Case Else
MsgBox(RX_STRING, MsgBoxStyle.OkOnly, "...")
End Select
TCP_CLIENT.Close()
Catch ex As Exception
End Try
TCP_LISTEN.Stop()
End Sub
Problem is if I send "beep" from the client program, rather than beeping the program instead follows the 'case else' and displays "beep" in a message box.
Any help would be very much appreciated. Thank you.