in src/Transport/Tcp/TcpTransport.cs [203:280]
public void Close()
{
Thread theReadThread = null;
lock(myLock)
{
if(closed.CompareAndSet(false, true))
{
try
{
socket.Shutdown(SocketShutdown.Both);
}
catch
{
}
try
{
if(null != socketWriter)
{
socketWriter.Close();
}
}
catch
{
}
finally
{
socketWriter = null;
}
try
{
if(null != socketReader)
{
socketReader.Close();
}
}
catch
{
}
finally
{
socketReader = null;
}
try
{
socket.Close();
}
catch
{
}
theReadThread = this.readThread;
this.readThread = null;
this.started = false;
}
}
// Don't block on closing the read thread within the lock scope.
if(null != theReadThread)
{
try
{
if(Thread.CurrentThread != theReadThread && theReadThread.IsAlive)
{
if(!theReadThread.Join((int) MAX_THREAD_WAIT.TotalMilliseconds))
{
theReadThread.Abort();
}
}
}
catch
{
}
}
}