private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.Text+="Server\n";
IPAddress ip=new IPAddress(new byte[] {127, 0, 0, 1});
TcpListener listener=new TcpListener(ip, 8500); listener.Start();
richTextBox1.Text+="Listen start ...\n"; while(true) {
TcpClient remoteClient=listener.AcceptTcpClient();
richTextBox1.Text+=string.Format("Client Connected! {0} --> {1}",
remoteClient.Client.LocalEndPoint, remoteClient.Client.RemoteEndPoint);
}
}
如果去掉
while(true) {
TcpClient remoteClient=listener.AcceptTcpClient();
richTextBox1.Text+=string.Format("Client Connected! {0} --> {1}",
remoteClient.Client.LocalEndPoint, remoteClient.Client.RemoteEndPoint);
}就是好使的,加上以后运行或者调试窗口不显示,任务管理器里有进程,把while拿掉也是一样的,求解。