日期:2014-05-17 浏览次数:20974 次
void ReceiveMsg()
{
while (true)
{
byte[] msgArr = new byte[1024 * 1024 * 1];//接收到的消息的缓冲区
int length = 0;
//接收服务端发送来的消息数据
length = sokClient.Receive(msgArr);//Receive会阻断线程
if (msgArr[0] == 0)//发送来的是文字
{
string strMsg = System.Text.Encoding.UTF8.GetString(msgArr, 1, length - 1);
if (strMsg == "1")
{
Form2 frm2 = new Form2();
frm2.Show(this);
}
}
}
}