为什么会死????

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 = "已停止监听!";
}
}

//???????这个地方不能同过,调试的时候到这里就死了,这是为什么?
...全文
41 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
daylove 2004-09-19
  • 打赏
  • 举报
回复
揭贴

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧