Esempio n. 1
0
        private static void processAccepted(Socket socket, EndPointListener listener)
        {
            HttpConnection conn = null;

            try {
                conn = new HttpConnection(socket, listener);
                lock (listener._unregisteredSync)
                    listener._unregistered[conn] = conn;

                conn.BeginReadRequest();
            }
            catch (Exception ex) {
                if (listener._logger != null)
                {
                    listener._logger.Error(ex.ToString());
                }
                if (conn != null)
                {
                    conn.Close(true);
                    return;
                }

                socket.Close();
            }
        }
Esempio n. 2
0
        private static void processAccepted(
            Socket socket, EndPointListener listener
            )
        {
            HttpConnection conn = null;

            try {
                conn = new HttpConnection(socket, listener);

                lock (listener._unregisteredSync)
                    listener._unregistered.Add(conn);

                conn.BeginReadRequest();
            }
            catch {
                if (conn != null)
                {
                    conn.Close(true);

                    return;
                }

                socket.Close();
            }
        }
Esempio n. 3
0
        private static void processAccepted(Socket socket, EndPointListener listener)
        {
            HttpConnection httpConnection = null;

            try
            {
                httpConnection = new HttpConnection(socket, listener);
                lock (listener._unregisteredSync)
                {
                    listener._unregistered[httpConnection] = httpConnection;
                }
                httpConnection.BeginReadRequest();
            }
            catch
            {
                if (httpConnection != null)
                {
                    httpConnection.Close(force: true);
                }
                else
                {
                    socket.Close();
                }
            }
        }
Esempio n. 4
0
        private static void processAccepted(Socket socket, EndPointListener listener)
#endif
        {
            listener.Log.Debug("processAccepted from: {0}", socket.RemoteEndPoint);

            HttpConnection conn = null;

            try
            {
                conn = new HttpConnection(socket, listener);
                lock (listener._unregisteredSync)
                    listener._unregistered[conn] = conn;

                conn.BeginReadRequest();
            }
            catch
            {
                if (conn != null)
                {
                    conn.Close(true);
                    return;
                }

                socket.Close();
            }
        }
        private static void processAccepted(Socket socket, EndPointListener listener)
        {
            HttpConnection httpConnection = null;

            try
            {
                httpConnection = new HttpConnection(socket, listener);
                object obj = listener._unregisteredSync;
                Monitor.Enter(obj);
                try
                {
                    listener._unregistered[httpConnection] = httpConnection;
                }
                finally
                {
                    Monitor.Exit(obj);
                }
                httpConnection.BeginReadRequest();
            }
            catch
            {
                if (httpConnection == null)
                {
                    socket.Close();
                }
                else
                {
                    httpConnection.Close(true);
                }
            }
        }
        private static void onAccept(object sender, EventArgs e)
        {
            SocketAsyncEventArgs socketAsyncEventArgs = (SocketAsyncEventArgs)e;
            EndPointListener     endPointListener     = (EndPointListener)socketAsyncEventArgs.UserToken;
            Socket socket = null;

            if (socketAsyncEventArgs.SocketError == SocketError.Success)
            {
                socket = socketAsyncEventArgs.AcceptSocket;
                socketAsyncEventArgs.AcceptSocket = null;
            }
            try
            {
                endPointListener._socket.AcceptAsync(socketAsyncEventArgs);
            }
            catch
            {
                if (socket != null)
                {
                    socket.Close();
                }
                return;
            }
            if (socket == null)
            {
                return;
            }
            HttpConnection httpConnection = null;

            try
            {
                httpConnection = new HttpConnection(socket, endPointListener, endPointListener._secure, endPointListener._cert);
                object syncRoot = ((ICollection)endPointListener._unregistered).SyncRoot;
                lock (syncRoot)
                {
                    endPointListener._unregistered[httpConnection] = httpConnection;
                }
                httpConnection.BeginReadRequest();
            }
            catch
            {
                if (httpConnection != null)
                {
                    httpConnection.Close(true);
                }
                else
                {
                    socket.Close();
                }
            }
        }
        private static void onAccept(object sender, EventArgs e)
        {
            var    args       = (SocketAsyncEventArgs)e;
            var    epListener = (EndPointListener)args.UserToken;
            Socket accepted   = null;

            if (args.SocketError == SocketError.Success)
            {
                accepted          = args.AcceptSocket;
                args.AcceptSocket = null;
            }

            try {
                epListener._socket.AcceptAsync(args);
            }
            catch {
                if (accepted != null)
                {
                    accepted.Close();
                }

                return;
            }

            if (accepted == null)
            {
                return;
            }

            HttpConnection conn = null;

            try {
                conn = new HttpConnection(accepted, epListener, epListener._secure, epListener._cert);
                lock (((ICollection)epListener._unregistered).SyncRoot)
                {
                    epListener._unregistered [conn] = conn;
                }

                conn.BeginReadRequest();
            }
            catch {
                if (conn != null)
                {
                    conn.Close(true);
                    return;
                }

                accepted.Close();
            }
        }
Esempio n. 8
0
        static void OnAccept(object sender, EventArgs e)
        {
            SocketAsyncEventArgs args = (SocketAsyncEventArgs)e;
            EndPointListener     epl  = (EndPointListener)args.UserToken;
            Socket accepted           = null;

            if (args.SocketError == SocketError.Success)
            {
                accepted          = args.AcceptSocket;
                args.AcceptSocket = null;
            }

            try {
                if (epl.sock != null)
                {
                    epl.sock.AcceptAsync(args);
                }
            } catch {
                if (accepted != null)
                {
                    try {
                        accepted.Close();
                    } catch {}
                    accepted = null;
                }
            }

            if (accepted == null)
            {
                return;
            }

            if (epl.secure && (epl.cert == null || epl.key == null))
            {
                accepted.Close();
                return;
            }
            HttpConnection conn = new HttpConnection(accepted, epl, epl.secure, epl.cert, epl.key);

            epl.unregistered [conn] = conn;
            conn.BeginReadRequest();
        }
Esempio n. 9
0
        private static void processAccepted(
            Socket socket, EndPointListener listener
            )
        {
            HttpConnection conn = null;

            try {
                conn = new HttpConnection(socket, listener);
            }
            catch (Exception) {
                // TODO: Logging.

                socket.Close();

                return;
            }

            lock (listener._unregisteredSync)
                listener._unregistered.Add(conn);

            conn.BeginReadRequest();
        }
Esempio n. 10
0
        private static void processAccepted(
            Socket socket, EndPointListener listener
            )
        {
            HttpConnection conn = null;

            try {
                conn = new HttpConnection(socket, listener);
            }
            catch (Exception e) {
                NTMiner.NTMinerConsole.DevException(e);

                socket.Close();

                return;
            }

            lock (listener._unregisteredSync)
                listener._unregistered.Add(conn);

            conn.BeginReadRequest();
        }