Exemplo n.º 1
0
        protected void OnReceiveUDP(IAsyncResult ar)
        {
            DateTime        dtReceive = DateTimePrecise.Now;
            BufferSocketRef objRef    = ar.AsyncState as BufferSocketRef;

            System.Net.EndPoint ep = (System.Net.EndPoint)m_tempRemoteEP;
            int nRecv = 0;

            try
            {
                nRecv = s.EndReceiveFrom(ar, ref ep);
                objRef.CheckInCopy(nRecv);
            }
            catch (SocketException e3) /// winso
            {
                objRef.CheckInCopy(nRecv);
                LogError(MessageImportance.High, "EXCEPTION", e3.ToString());

                /// Get 10054 if the other end is not listening (ICMP returned)... fixed above with IOControl
                if (e3.ErrorCode != 10054)
                {
                }
                return;
            }
            catch (ObjectDisposedException e4) // socket was closed
            {
                objRef.CheckInCopy(nRecv);
                this.LogWarning(MessageImportance.Low, "EXCEPTION", e4.ToString());
                return;
            }
            catch (Exception e5)
            {
                objRef.CheckInCopy(nRecv);
                LogError(MessageImportance.High, "EXCEPTION", e5.ToString());
                return;
            }

            System.Net.IPEndPoint ipep = (System.Net.IPEndPoint)ep;
            OnRecv(objRef.bRecv, nRecv, ipep, dtReceive);
        }
Exemplo n.º 2
0
        protected void DoReceive()
        {
            lock (SyncRoot)
            {
                if (m_bReceive == false)
                {
                    return;
                }


                System.Net.EndPoint ep = (System.Net.EndPoint)m_tempRemoteEP;
                try
                {
                    if (m_Logger != null)
                    {
                        LogMessage(MessageImportance.Lowest, this.OurGuid, string.Format("Called DoReceive for {0}", s.LocalEndPoint));
                    }
                    BufferSocketRef objRef = new BufferSocketRef(this);
                    s.BeginReceiveFrom(objRef.bRecv, 0, m_nBufferSize, System.Net.Sockets.SocketFlags.None, ref ep, asyncb, objRef);
                }
                catch (SocketException e3) /// winso
                {
                    LogError(MessageImportance.High, "SocketEXCEPTION", string.Format("{0} - {1}", e3.ErrorCode, e3.ToString()));
                    return;
                }
                catch (ObjectDisposedException e4) // socket was closed
                {
                    LogError(MessageImportance.High, "ObjectDisposedEXCEPTION", e4.ToString());
                    return;
                }
                catch (Exception e5)
                {
                    LogError(MessageImportance.High, "EXCEPTION", e5.ToString());
                    return;
                }
            }
            return;
        }