wm5的问题,请教牛人,急
我做一个PDA socket通信的东西,如下
Server端:vs2005 C# windows application
一个按钮,起动监听,端口8000;一个listbox,显示客户端发来的字符
client端:vs2005 C# windows CE device application
一个输Server IP地址的textbox;一个输message的textbox
一个Connet按钮,连接服务器;
IPAddress ipRemote = IPAddress.Parse(textBox1.Text);
IPEndPoint iep = new IPEndPoint(ipRemote, 8000);
TcpClient tcpClient = new TcpClient();
tcpClient.Connect(iep);
nsStream = tcpClient.GetStream();
swWriter = new StreamWriter(nsStream);
button1.Enabled = false;
button2.Enabled = true;
tcpConnect = true;
statusBar1.Text = "Connected!";
到这里没有问题。
一个Send按钮,发送字符
try
{
swWriter.WriteLine(textBox2.Text);
swWriter.Flush();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
这个按钮这一步 swWriter.Flush(); 出错!
System.IO.IOException:Unalbe to write data to the transport connection.
-->System.Net.Sockets.SocketException: An existing connection was forcibly colsed by the remote host
请教是什么缘故?要怎么解决啊?