Thread: NIO Framework

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 NIO Framework 
    Registered Member

    Join Date
    Jan 2013
    Posts
    364
    Thanks given
    14
    Thanks received
    324
    Rep Power
    548
    I wrote this awhile back and make improvements here and there, and it's what I run my server from. Any suggestions or improvements? I'm completely open to them. Source code is included.

    http://www.filedropper.com/nioframework
    nio_framework.zip
    Download nio_framework.zip from Sendspace.com - send big files the easy way

    Pretty simple to use

    Code:
    import java.nio.ByteBuffer;
    
    import com.palidino.nio.NIOServer;
    import com.palidino.nio.Session;
    import com.palidino.nio.SessionHandler;
    
    public class MyHandler implements SessionHandler {
        private NIOServer nioServer = new NIOServer();
    
        public MyHandler() throws Exception {
            nioServer.setSessionHandler(this);
            nioServer.setLogDirectory("./logs");
            nioServer.setMaxTotalConnections(2000);
            nioServer.setReadBufferSize(8192); // 8kb
            nioServer.setWriteBufferSize(16384); // 16kb
            nioServer.setMaxConnectionsPerIPAddress(3);
            nioServer.setSocketIOIdleTimeout(30); // 30 seconds
            nioServer.setBanLength(60); // 60 seconds
            nioServer.start("0.0.0.0", 43594); // bind to all IPs on port 43594
        }
    
        public void close() {
            nioServer.close();
        }
    
        @Override
        public void accept(Session session) {
            //session.setAttachment(SOME_OBJECT);
            System.out.println("Connection received from: " + session.getRemoteAddress());
        }
    
        @Override
        public void read(Session session, byte[] bytes) {
            //Object o = session.getAttachment();
        }
    
        @Override
        public void exception(Session session, Exception exception) {
            session.close();
        }
    
        @Override
        public void closed(Session session) { }
    }
    Writing data isn't much harder
    Code:
    import com.palidino.nio.WriteCompleteEvent;
    import com.palidino.nio.WriteEvent;
    import com.palidino.nio.Session;
    
    WriteEvent writeEvent = session.write(bytes, 0, bytes.length);
    OR
    WriteEvent writeEvent = session.writeClone(bytes, 0, bytes.length);
    
    IF you want to trigger an action when this write completes
    writeEvent.setWriteCompleteEvent(new WriteCompleteEvent() {
        @Override
        public void complete(Session session) {
            session.close();
        }
    });
    Reply With Quote  
     

  2. Thankful user:


  3. #2  
    Banned
    Join Date
    Oct 2013
    Age
    25
    Posts
    685
    Thanks given
    15
    Thanks received
    68
    Rep Power
    0
    Any sort of media?
    Reply With Quote  
     

  4. Thankful user:


  5. #3  


    RS Wiki's Avatar
    Join Date
    Mar 2011
    Age
    29
    Posts
    9,688
    Thanks given
    1,752
    Thanks received
    3,103
    Rep Power
    5000
    Quote Originally Posted by Driman View Post
    Any sort of media?
    I think it's just a basic framework to start building off of, nothing actually viewable here
    All the best,
    Wiki




    coming soon
    Reply With Quote  
     

  6. #4  
    Banned
    Join Date
    Oct 2013
    Age
    25
    Posts
    685
    Thanks given
    15
    Thanks received
    68
    Rep Power
    0
    Quote Originally Posted by Whale Hunter View Post
    I think it's just a basic framework to start building off of, nothing actually viewable here
    The basic black screen will do.
    Reply With Quote  
     

  7. #5  
    Registered Member
    Join Date
    Sep 2013
    Posts
    105
    Thanks given
    13
    Thanks received
    28
    Rep Power
    10
    Will take a look. Its nice to see you release something.
    Quote Originally Posted by Driman View Post
    The basic black screen will do.
    This doesnt even have that. This is more like a networking api.
    Reply With Quote  
     

  8. #6  
    The Meme God

    4DFo's Avatar
    Join Date
    Dec 2013
    Age
    26
    Posts
    616
    Thanks given
    54
    Thanks received
    81
    Rep Power
    185
    Tbh. In all honesty. I'm gonna work the HELL outta this.
    I've heard some good things about NIO, and it looks clean af.
    Would recommend.

    Attached image
    Attached image
    Rest easy, Brian x2. Suicide is never the answer.
    Reply With Quote  
     

  9. #7  
    Banned

    Join Date
    May 2011
    Posts
    1,077
    Thanks given
    236
    Thanks received
    230
    Rep Power
    0
    Thanks for the share.
    Reply With Quote  
     

  10. #8  
    Aymen
    Guest
    good job
    Reply With Quote  
     

  11. #9  
    Banned
    Join Date
    Mar 2014
    Posts
    628
    Thanks given
    109
    Thanks received
    181
    Rep Power
    0
    Quote Originally Posted by ThePalidino View Post
    I wrote this awhile back and make improvements here and there, and it's what I run my server from. Any suggestions or improvements? I'm completely open to them. Source code is included.

    Free File Hosting - Online Storage; Upload Mp3, Videos, Music. Backup Files
    nio_framework.zip
    Download nio_framework.zip from Sendspace.com - send big files the easy way

    Pretty simple to use

    Code:
    import java.nio.ByteBuffer;
    
    import com.palidino.nio.NIOServer;
    import com.palidino.nio.Session;
    import com.palidino.nio.SessionHandler;
    
    public class MyHandler implements SessionHandler {
        private NIOServer nioServer = new NIOServer();
    
        public MyHandler() throws Exception {
            nioServer.setSessionHandler(this);
            nioServer.setLogDirectory("./logs");
            nioServer.setMaxTotalConnections(2000);
            nioServer.setReadBufferSize(8192); // 8kb
            nioServer.setWriteBufferSize(16384); // 16kb
            nioServer.setMaxConnectionsPerIPAddress(3);
            nioServer.setSocketIOIdleTimeout(30); // 30 seconds
            nioServer.setBanLength(60); // 60 seconds
            nioServer.start("0.0.0.0", 43594); // bind to all IPs on port 43594
        }
    
        public void close() {
            nioServer.close();
        }
    
        @Override
        public void accept(Session session) {
            //session.setAttachment(SOME_OBJECT);
            System.out.println("Connection received from: " + session.getRemoteAddress());
        }
    
        @Override
        public void read(Session session, byte[] bytes) {
            //Object o = session.getAttachment();
        }
    
        @Override
        public void exception(Session session, Exception exception) {
            session.close();
        }
    
        @Override
        public void closed(Session session) { }
    }
    Writing data isn't much harder
    Code:
    import com.palidino.nio.WriteCompleteEvent;
    import com.palidino.nio.WriteEvent;
    import com.palidino.nio.Session;
    
    WriteEvent writeEvent = session.write(bytes, 0, bytes.length);
    OR
    WriteEvent writeEvent = session.writeClone(bytes, 0, bytes.length);
    
    IF you want to trigger an action when this write completes
    writeEvent.setWriteCompleteEvent(new WriteCompleteEvent() {
        @Override
        public void complete(Session session) {
            session.close();
        }
    });
    Wouldn't mind taking a look at this, been interested in learning NIO. Would you mind uploading again?
    Reply With Quote  
     

  12. #10  
    Extreme Donator NIO Framework Market Banned



    Join Date
    Dec 2010
    Age
    25
    Posts
    6,060
    Thanks given
    1,692
    Thanks received
    1,238
    Rep Power
    1765
    nio_framework.zip still works.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 58
    Last Post: 05-23-2009, 07:55 PM
  2. Replies: 25
    Last Post: 03-21-2009, 08:33 AM
  3. Replies: 45
    Last Post: 01-09-2009, 11:04 PM
  4. [Incomplete]: NIO Framework
    By blakeman8192 in forum Downloads
    Replies: 18
    Last Post: 12-05-2008, 12:17 AM
  5. Nio Framework
    By xiphias_ in forum Downloads
    Replies: 5
    Last Post: 09-24-2008, 10:09 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •