Package one.nio.net

Examples of one.nio.net.Session


            workers = null;
        }
    }

    public Session createSession(Socket socket) {
        return new Session(socket);
    }
View Full Code Here


        while (server.isRunning()) {
            Socket socket = null;
            try {
                socket = serverSocket.accept();
                socket.setBlocking(false);
                Session session = server.createSession(socket);
                getSmallestSelector().register(session);
                acceptedSessions++;
            } catch (Exception e) {
                if (server.isRunning()) {
                    log.error("Cannot accept incoming connection", e);
View Full Code Here

        final byte[] buffer = new byte[BUFFER_SIZE];

        while (server.isRunning()) {
            int ready = 0;
            for (Iterator<Session> selectedSessions = selector.select(); selectedSessions.hasNext(); ready++) {
                Session session = selectedSessions.next();
                try {
                    session.process(buffer);
                } catch (SocketException e) {
                    if (server.isRunning() && log.isDebugEnabled()) {
                        log.debug("Connection closed: " + session.clientIp());
                    }
                    session.close();
                } catch (Throwable e) {
                    if (server.isRunning()) {
                        log.error("Cannot process session from " + session.clientIp(), e);
                    }
                    session.close();
                }
            }

            operations++;
            sessions += ready;
View Full Code Here

TOP

Related Classes of one.nio.net.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.