我有以下代码,它接收来自我也开发的代理应用程序的输入。
我正在尝试减少来自代理的所有额外空白,但无论我做什么,结果仍然有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)
结果永远不会改变,现在我被卡住了。
任何帮助,当然感激不尽!
由于
答案 0 :(得分:0)
这是空字节...这解决了它。
result = result.Trim(result.Trim(chr(0)))