[java.nio] Blocking mode for a while - How ?

Discussion in 'Java' started by xEM, Apr 27, 2004.

  1. xEM

    xEM Guest

    I'm using selector to manage connection on server. When server get an
    incomming connection register this connection in non-blocking mode for
    making readiness selection on it. In some moment i want to operate
    with clients channels with blocking mode... but i can't change channel
    to blocking mode, because is registered with selector in non-blocking
    mode - i get IllegalBlockingModeException. How can i operate for a
    while in blocking mode, but not to lose possibility readiness
    selection on channel?


    --
    pozdr.;)
    ~xEM
     
    xEM, Apr 27, 2004
    #1
    1. Advertising

  2. xEM

    HDSkiFreak Guest

    GReetings:

    if your channel inherits from an AbstractSelectableChannel (all
    sockets do), then you can use the call:

    Object mutex = channel.blockingLock()
    and wrap your blocking sections in a synchronized segment using the
    returned mutex object.

    Look at the NIO guide, or check out the O'Reilly NIO book for
    examples. You can also try google'ing the API call for some examples.

    Best Regards,

    HDSkiFreak

    On Tue, 27 Apr 2004 10:41:48 +0000 (UTC), xEM <> wrote:

    >I'm using selector to manage connection on server. When server get an
    >incomming connection register this connection in non-blocking mode for
    >making readiness selection on it. In some moment i want to operate
    >with clients channels with blocking mode... but i can't change channel
    >to blocking mode, because is registered with selector in non-blocking
    >mode - i get IllegalBlockingModeException. How can i operate for a
    >while in blocking mode, but not to lose possibility readiness
    >selection on channel?
     
    HDSkiFreak, May 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Roberts
    Replies:
    0
    Views:
    1,692
    Dave Roberts
    Jul 29, 2003
  2. iksrazal

    NIO with timeouts != NIO?

    iksrazal, Jun 17, 2004, in forum: Java
    Replies:
    1
    Views:
    6,412
    iksrazal
    Jun 18, 2004
  3. John J Lee
    Replies:
    3
    Views:
    549
    bruno at modulix
    Dec 1, 2005
  4. brieuc
    Replies:
    5
    Views:
    2,283
    Esmond Pitt
    Mar 20, 2007
  5. Zachary  Turner
    Replies:
    12
    Views:
    543
    Arne Vajhøj
    Jul 3, 2008
Loading...

Share This Page