예제 #1
0
        /// <summary>
        /// Is called when IPv6 socket has received data.
        /// </summary>
        /// <param name="ar">The result of the asynchronous operation.</param>
        private void IPv6ReceiveCompleted(IAsyncResult ar)
        {
            try{
                if (m_IsDisposed)
                {
                    return;
                }

                EndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0);
                int      count    = m_pIPv6Socket.EndReceiveFrom(ar, ref remoteEP);

                DnsServerResponse serverResponse = ParseQuery((byte[])ar.AsyncState);
                DnsTransaction    transaction    = null;
                // Pass response to transaction.
                if (m_pTransactions.TryGetValue(serverResponse.ID, out transaction))
                {
                    transaction.ProcessResponse(serverResponse);
                }
                // No such transaction or transaction has timed out before answer received.
                //else{
                //}

                // Cache query.
                if (m_UseDnsCache && serverResponse.ResponseCode == RCODE.NO_ERROR)
                {
                    DnsCache.AddToCache(transaction.QName, transaction.QType, serverResponse);
                }
            }
            catch {
                // Skip receiving socket errors.
            }

            try{
                StartWaitingIPv6Packet();
            }
            catch {
            }
        }