0
我跑我的服务器succsessfully但是当我打印,我以前打印在控制台屏幕称呼我是怎么回事的数据,我想显示所有的文本框,但它不显示,而当我关闭来自客户端的连接它显示所有的信息。为什么会发生。?如何在服务器表单文本框中显示数据?
这里是我的代码
public void GetData()
{
Form1 f = new Form1();
string ipadd = getip();
IPAddress ipAd = IPAddress.Parse("192.168.0.15"); //use local m/c IP address, and use the same in the client
// IPAddress ip = IPAddress.Parse(ipadd);
txtip.Text = ipAd.ToString();
txtport.Text = "3030";
/* Initializes the Listener */
TcpListener myList = new TcpListener(ipAd, 3030);
/* Start Listeneting at the specified port */
myList.Start();
txtdata.Text = "The server is running at port 3030...";
txtdata.Text = txtdata.Text + Environment.NewLine + "The local End point is :" + myList.LocalEndpoint;
txtdata.Text = txtdata.Text + Environment.NewLine + "Waiting for a connection.....";
Socket s = myList.AcceptSocket();
txtdata.Text = txtdata.Text + Environment.NewLine +"Connection accepted from " + s.RemoteEndPoint;
// txtdata.Text = "Connection accepted from " + s.RemoteEndPoint;
}
看代码当我写在控制台上的数据它的工作原理,但同样我要打印txtdata(文本框),但它不打印,直到连接关闭上述由客户。