Hi,
When I'm doing BinaryFormatter .Deserialize() over a TCP socket. When I'm
closing the TcpListener by invoking the TcpListener.Sto p(); I get:
System.IO.IOExc eption with message "Unable to read data from the transport
connection." that InnerException of type System.Net.Sock ets.SocketExcep tion
saying "An established connection was aborted by the software in your host
machine".
The code I'm using is (it's not the complete code because the complete code
is very long and threaded):
-------------------------------------------------------------
string serverIP = "some IP address";
int port = 3001;
TcpListener m_server;
m_server = new TcpListener( System.Net.IPAd dress.Parse(ser verIP), port );
Socket m_socket = m_server.Accept Socket();
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er formatter =
new System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er();
while( true )
{
NetworkStream networkStream = new NetworkStream(m _socket);
MyObjectType obj = formatter.Deser ialize(networkS tream) as MyObjectType;
// throw the IOException when the TcpListener is closed by TcpListener.Sto p();
}
-------------------------------------------------------------
Can anybody tell me how to avoid this exception?
---------
Thanks
Sharon
When I'm doing BinaryFormatter .Deserialize() over a TCP socket. When I'm
closing the TcpListener by invoking the TcpListener.Sto p(); I get:
System.IO.IOExc eption with message "Unable to read data from the transport
connection." that InnerException of type System.Net.Sock ets.SocketExcep tion
saying "An established connection was aborted by the software in your host
machine".
The code I'm using is (it's not the complete code because the complete code
is very long and threaded):
-------------------------------------------------------------
string serverIP = "some IP address";
int port = 3001;
TcpListener m_server;
m_server = new TcpListener( System.Net.IPAd dress.Parse(ser verIP), port );
Socket m_socket = m_server.Accept Socket();
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er formatter =
new System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er();
while( true )
{
NetworkStream networkStream = new NetworkStream(m _socket);
MyObjectType obj = formatter.Deser ialize(networkS tream) as MyObjectType;
// throw the IOException when the TcpListener is closed by TcpListener.Sto p();
}
-------------------------------------------------------------
Can anybody tell me how to avoid this exception?
---------
Thanks
Sharon
Comment