Results 1 to 6 of 6
  1. #1
    prich is offline Member
    Join Date
    Aug 2009
    Posts
    7
    Rep Power
    0

    Default asychronous io with callbacks

    Hello there!

    I want to implement a serverconnection that asychronous write and read with callbacks. Can you guys give me any tutorial?

    I tried this with java.nio but the problem is that if i set intresOPs to read the selector.select(); will NEVER select for read (-> deadlock), even if the server is writing!

    Basically i want something like this:

    a networkthread that runs and blocks at a point until the socket became ready for read or write.
    then once in a while i put some bytebuffer onto a stack that should be send, and also read data!

    thx prich
    Last edited by prich; 10-22-2009 at 06:40 PM.

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    i found this very helpful: Rox Java NIO Tutorial

    I had to tweak it a bit, but overall it worked for me.
    My Hobby Project: LegacyClone

  3. #3
    prich is offline Member
    Join Date
    Aug 2009
    Posts
    7
    Rep Power
    0

    Default

    I'm afraid i started with this tutorial, and it does not work :(

  4. #4
    prich is offline Member
    Join Date
    Aug 2009
    Posts
    7
    Rep Power
    0

    Default

    how would i implement something like stream.BeginRecieve(..., callback, ...) and stream.BeginSend(...,callback,...); like in c#?

  5. #5
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    5

    Default

    Write your own or maybe try: Apache MINA - Index
    My Hobby Project: LegacyClone

  6. #6
    prich is offline Member
    Join Date
    Aug 2009
    Posts
    7
    Rep Power
    0

    Default

    Apache MINA is a network application framework which helps users develop high performance and high scalability network applications easily. It provides an abstract event-driven asynchronous API over various transports such as TCP/IP and UDP/IP via Java NIO.
    sounds great! thank you

Similar Threads

  1. Callbacks
    By ImplicitCharm in forum New To Java
    Replies: 1
    Last Post: 08-18-2009, 11:03 PM
  2. Replies: 0
    Last Post: 03-31-2008, 10:18 AM
  3. Replies: 0
    Last Post: 03-31-2008, 10:16 AM
  4. Replies: 0
    Last Post: 09-28-2007, 12:50 PM
  5. Replies: 0
    Last Post: 09-28-2007, 12:49 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
  •