服务器端做个触发 当收到信息后,自动回复客户端
while ((length = s.Receive(buffer)) > 0)
{
string receiveStr = System.Text.Encoding.UTF8.GetString(buffer, 0, length);
if (receiveStr.StartsWith("head:") && receiveStr.EndsWith(":end"))
{
receiveStr = receiveStr.Remove(receiveStr.IndexOf(":end"));
string[] arrs = receiveStr.Replace("head:", "").Split('@');
byte[] sendMsg = System.Text.Encoding.UTF8.GetBytes("ok");
s.Send(sendMsg);
}
}