|
|
@@ -99,20 +99,27 @@ namespace ClassFile
|
|
|
|
|
|
private void WatchConnecting()
|
|
|
{
|
|
|
- socConnection = socketWatch.Accept();
|
|
|
- while (true) //持续不断监听客户端发来的请求
|
|
|
+ while (true)
|
|
|
{
|
|
|
- byte[] data = new byte[1024];
|
|
|
- socConnection.Receive(data);
|
|
|
- int length = data[5];
|
|
|
- byte[] datashow = new byte[length + 6];
|
|
|
- for (int i = 0; i <= length + 5; i++)
|
|
|
+ socConnection = socketWatch.Accept();
|
|
|
+ while (true) //持续不断监听客户端发来的请求
|
|
|
{
|
|
|
- datashow[i] = data[i];
|
|
|
+ byte[] data = new byte[1024];
|
|
|
+ socConnection.Receive(data);
|
|
|
+ if (data[0] == 0)
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ int length = data[5];
|
|
|
+ byte[] datashow = new byte[length + 6];
|
|
|
+ for (int i = 0; i <= length + 5; i++)
|
|
|
+ {
|
|
|
+ datashow[i] = data[i];
|
|
|
+ }
|
|
|
+ string str = Encoding.ASCII.GetString(datashow);
|
|
|
+ richtext.AppendText("来自" + socConnection.RemoteEndPoint.ToString() + "的消息:" + str + "\n");
|
|
|
+ LogManager.DoLog(str);
|
|
|
}
|
|
|
- string str = Encoding.ASCII.GetString(datashow);
|
|
|
- richtext.AppendText("来自" + socConnection.RemoteEndPoint.ToString() + "的消息:" + str + "\n");
|
|
|
- LogManager.DoLog(str);
|
|
|
}
|
|
|
}
|
|
|
|