G
Guest
Hi,
When I'm doing BinaryFormatter.Deserialize() over a TCP socket. When I'm
closing the TcpListener by invoking the TcpListener.Stop(); I get:
System.IO.IOException with message "Unable to read data from the transport
connection." that InnerException of type System.Net.Sockets.SocketException
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.IPAddress.Parse(serverIP), port );
Socket m_socket = m_server.AcceptSocket();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
while( true )
{
NetworkStream networkStream = new NetworkStream(m_socket);
MyObjectType obj = formatter.Deserialize(networkStream) as MyObjectType;
// throw the IOException when the TcpListener is closed by TcpListener.Stop();
}
When I'm doing BinaryFormatter.Deserialize() over a TCP socket. When I'm
closing the TcpListener by invoking the TcpListener.Stop(); I get:
System.IO.IOException with message "Unable to read data from the transport
connection." that InnerException of type System.Net.Sockets.SocketException
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.IPAddress.Parse(serverIP), port );
Socket m_socket = m_server.AcceptSocket();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter =
new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
while( true )
{
NetworkStream networkStream = new NetworkStream(m_socket);
MyObjectType obj = formatter.Deserialize(networkStream) as MyObjectType;
// throw the IOException when the TcpListener is closed by TcpListener.Stop();
}