public void Reconnect()
{
Utils.Trace("TcpTransportChannel RECONNECT: Reconnecting to {0}.", m_url);
lock (m_lock)
{
// the new channel must be created first because WinSock will reuse sockets and this
// can result in messages sent over the old socket arriving as messages on the new socket.
// if this happens the new channel is shutdown because of a security violation.
TcpClientChannel channel = m_channel;
m_channel = null;
// reconnect.
OpenOnDemand();
// begin connect operation.
IAsyncResult result = m_channel.BeginConnect(m_url, m_operationTimeout, null, null);
m_channel.EndConnect(result);
// close existing channel.
if (channel != null)
{
try
{
channel.Close(1000);
}
catch (Exception)
{
// do nothing.
}
finally
{
channel.Dispose();
}
}
}
}