0
收到的消息我有以下代碼,它接收我也開發的代理程序應用程序的輸入。如何修剪從tcpClient.GetStream()
我想減磅所有來自劑,但無論我做什麼,結果仍然有8192這裏長度額外的空格是我迄今爲止...
Private Sub HandleClientComm(ByVal client As Object)
Dim tcpClient As TcpClient = DirectCast(client, TcpClient)
Dim clientStream As NetworkStream = tcpClient.GetStream()
Dim message As Byte() = New Byte(8191) {}
Dim bytesRead As Integer
Dim result As String
While True
message = New Byte(8191) {}
bytesRead = 0
Try
bytesRead = clientStream.Read(message, 0, 8191) 'blocks until a client sends a message
Catch
bytesRead = 0
End Try
result = ""
result = System.Text.Encoding.Default.GetString(message).ToString.Trim
Logger(result.Length)
Logger("""" & result & """", "RECV")
result.Length = 8192,結果本身仍然是一個大的字符串,尾隨空格。我試過很多東西試圖擺脫它..
result = CType(result,String).Trim
result = trim(result)
結果永遠不會改變,現在我卡住了。
任何幫助,當然感激!
謝謝