客户端
public void ReceServerData()
{
while (stopFlag)
{
byte[] buffer = new byte[2048];
try
{
do
{
netstream.Read(buffer, 0, buffer.Length);
}
while (netstream.DataAvailable);
}
catch (Exception es)
{
MessageBox.Show(es.ToString());//运行错误,显示无法从传输中获取数据,
}
string connResult = Encoding.Unicode.GetString(buffer).TrimEnd('\0');
MessageBox.Show(connResult);
}
}
}
服务端发送第一条消息后客户端能正确收到connResult,可发送第二条消息客户端就无法收到,然后客户端报错,无法从输入中获取数据,netstream.DataAvailable为什么变成了false,请问哪么高手给解决一下
public void ReceServerData()
{
while (stopFlag)
{
byte[] buffer = new byte[2048];
try
{
do
{
netstream.Read(buffer, 0, buffer.Length);
}
while (netstream.DataAvailable);
}
catch (Exception es)
{
MessageBox.Show(es.ToString());//运行错误,显示无法从传输中获取数据,
}
string connResult = Encoding.Unicode.GetString(buffer).TrimEnd('\0');
MessageBox.Show(connResult);
}
}
}
服务端发送第一条消息后客户端能正确收到connResult,可发送第二条消息客户端就无法收到,然后客户端报错,无法从输入中获取数据,netstream.DataAvailable为什么变成了false,请问哪么高手给解决一下
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货