/// <summary>
/// Handles a new connection.
/// </summary>
private void OnAcceptIPv6(IAsyncResult result)
{
TcpServerChannel channel = null;
lock (m_lock)
{
// check if the socket has been closed.
if (m_listeningSocketIPv6 == null)
{
return;
}
try
{
// accept the socket.
Socket socket = m_listeningSocketIPv6.EndAccept(result);
// create the channel to manage incoming messages.
channel = new TcpServerChannel(
m_listenerId,
this,
m_bufferManager,
m_quotas,
m_serverCertificate,
m_descriptions);
//channel.ServerCertificateChain = m_serverCertificateChain;
// start accepting messages on the channel.
channel.Attach(++m_lastChannelId, socket);
// save the channel for shutdown and reconnects.
m_channels.Add(m_lastChannelId, channel);
if (m_callback != null)
{
channel.SetRequestReceivedCallback(new TcpChannelRequestEventHandler(OnRequestReceived));
}
// Utils.Trace("Channel {0} created.", m_lastChannelId);
}
catch (Exception e)
{
Utils.Trace(e, "Unexpected error accepting a new connection.");
}
// go back and wait for the next connection.
try
{
m_listeningSocketIPv6.BeginAccept(OnAcceptIPv6, null);
}
catch (Exception e)
{
Utils.Trace(e, "Unexpected error listening for a new IPv6 connection.");
}
}
}