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(文本框),但它不打印,直到連接關閉上述由客戶。