public void ReceiveCallback(IAsyncResult ar)
        {
            SIPConnection sipTLSConnection = (SIPConnection)ar.AsyncState;

            if (sipTLSConnection != null && sipTLSConnection.SIPStream != null && sipTLSConnection.SIPStream.CanRead)
            {
                try
                {
                    int bytesRead = sipTLSConnection.SIPStream.EndRead(ar);
                    if (sipTLSConnection.SocketReadCompleted(bytesRead))
                    {
                        sipTLSConnection.SIPStream.BeginRead(sipTLSConnection.SocketBuffer,
                                                             sipTLSConnection.SocketBufferEndPosition,
                                                             MaxSIPTCPMessageSize - sipTLSConnection.SocketBufferEndPosition,
                                                             new AsyncCallback(ReceiveCallback), sipTLSConnection);
                    }
                }
                catch (SocketException sockExcp) // Occurs if the remote end gets disconnected.
                {
                    logger.Warn("SocketException SIPTLSChannel ReceiveCallback. " + sockExcp);
                }
                catch (Exception excp)
                {
                    logger.Warn("Exception SIPTLSChannel ReceiveCallback. " + excp);
                    SIPTLSSocketDisconnected(sipTLSConnection.RemoteEndPoint);
                }
            }
        }
Beispiel #2
0
        public void ReceiveCallback(IAsyncResult ar)
        {
            SIPConnection sipTCPConnection = (SIPConnection)ar.AsyncState;

            try
            {
                int bytesRead = sipTCPConnection.SIPStream.EndRead(ar);
                if (sipTCPConnection.SocketReadCompleted(bytesRead))
                {
                    sipTCPConnection.SIPStream.BeginRead(sipTCPConnection.SocketBuffer,
                                                         sipTCPConnection.SocketBufferEndPosition,
                                                         MaxSIPTCPMessageSize - sipTCPConnection.SocketBufferEndPosition,
                                                         new AsyncCallback(ReceiveCallback), sipTCPConnection);
                }
            }
            catch (SocketException) // Occurs if the remote end gets disconnected.
            {
            }
            catch (Exception excp)
            {
                Logger.Logger.Error("Exception SIPTCPChannel ReceiveCallback. ->" + excp.Message);
                SIPTCPSocketDisconnected(sipTCPConnection.RemoteEndPoint);
            }
        }