I have a problem with TcpClient....
-
How can I to determine when socket connected to my TcpClient is close connection? I do this...
IPAddress ipAddress = Dns.Resolve(Dns.GetHostName()).AddressList[0]; TCPListiner = new TcpListener(ipAddress,PortNumber); TCPListiner.Start(); while(true) { if (TCPListiner.Pending()) { TcpClient TCPClient = TCPListiner.AcceptTcpClient(); NetworkStream LNS = TCPClient.GetStream(); } }
then I send some text throw NetworkStream LNS. Client can close connection. And result this.... System.IO.IOException: Unable to write data to the transport connection. ---> System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, So cketFlags socketFlags) at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)