in src/main/csharp/Transport/Tcp/TcpTransport.cs [271:323]
public void ReadLoop()
{
// This is the thread function for the reader thread. This runs continuously
// performing a blokcing read on the socket and dispatching all commands
// received.
//
// Exception Handling
// ------------------
// If an Exception occurs during the reading/marshalling, then the connection
// is effectively broken because position cannot be re-established to the next
// message. This is reported to the app via the exceptionHandler and the socket
// is closed to prevent further communication attempts.
//
// An exception in the command handler may not be fatal to the transport, so
// these are simply reported to the exceptionHandler.
//
while(!closed.Value)
{
Command command = null;
try
{
command = (Command) Wireformat.Unmarshal(socketReader);
}
catch(Exception ex)
{
command = null;
if(!closed.Value)
{
// Close the socket as there's little that can be done with this transport now.
Close();
if(!seenShutdown)
{
this.exceptionHandler(this, ex);
}
}
break;
}
try
{
if(command != null)
{
this.commandHandler(this, command);
}
}
catch(Exception e)
{
this.exceptionHandler(this, e);
}
}
}