0
因此,我无法读取通过Tcp流发送的字符串。我正在使用此代码发送。从TcpClient读取字符串
byte[] bytes = ASCIIEncoding.ASCII.GetBytes("connect");
NetworkStream stream = client.GetStream();
StreamWriter writer = new StreamWriter(stream);
writer.Write(bytes);
writer.Close();
而这种代码改为:
public void getConnectionString()
{
NetworkStream ns = client.GetStream();
byte[] bytes = new byte[client.ReceiveBufferSize];
ns.Read(bytes, 0, bytes.Length);
string info = Encoding.ASCII.GetString(bytes);
MessageBox.Show(info);
}
但是,这一切正在恢复的系统:字节[]
难道不应该返回字符串?我究竟做错了什么?