我有这个System.Net.Sockets.TcpClient
。我可以建立连接并将数据包准确地写入它。问题是要按原样读取数据包(被嗅探器以十六进制形式捕获,如 0F 03 56 56 等)
我尝试查看示例,GetStream.write
但我没有以这种方式阅读它们。我还尝试使用流式阅读器,然后将数据包转换为十六进制,但我连接的东西发送搞砸的数据包,这些数据包无法转换或简单的不是字符串形式。
我希望我足够清楚。
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
' Read can return anything from 0 to numBytesToRead.
' This method blocks until at least one byte is read.
netStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Returns the data received from the host to the console.
Dim returndata As String = Encoding.ASCII.GetString(bytes)