为什么会死????
yjhyn 2004-03-05 02:55:52 private void Listen()
{
try
{
IPAddress localAddr = IPAddress.Parse("127.0.0.1");
IPEndPoint local = new IPEndPoint(localAddr,5656);
TcpListener tcpl = new TcpListener(local);
tcpl.Start();
flag = true;
statusBar1.Text = "正在监听...";
while(flag==true)
{
Socket s = tcpl.AcceptSocket();//???????
byte[] stream = new Byte[80];
int i=s.Receive(stream);
string message = System.Text.Encoding.UTF8.GetString(stream);
richTextBox1.AppendText(message);
}
}
catch(System.Security.SecurityException)
{
MessageBox.Show("防火墙安全错误!","错误",MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
catch(Exception)
{
statusBar1.Text = "已停止监听!";
}
}
//???????这个地方不能同过,调试的时候到这里就死了,这是为什么?