写一个聊天的程序可是有点问题,帮忙看看
public void Listen()
{
try
{
TcpListener tcpl = new TcpListener(8080);
tcpl.Start();
toolStripStatusLabel1.Text = "正在监听。。。";
while (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)
{
toolStripStatusLabel1.Text = "停止监听";
}
}
谢谢拉!!!