setSoTimeout in nonblocking mode?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KimTaehwan

    setSoTimeout in nonblocking mode?

    I want to be throw exception when one thread wait to read no data from
    a remote source for long time.

    This can be done in pre-1.4 enviroment like the following.

    ---------------------------------------------------------------------------
    Socket sock = new Sokcet("REMOTE_ Addr", "REMOTE_por t");
    sock.setSoTimeo ut(10000);
    InputStream in = sock.getInputSt ream();
    in.read(); // If some data would not be read in 10000ms, exception
    would be throwed..
    ---------------------------------------------------------------------------


    But in nio of 1.4, how?
  • SPG

    #2
    Re: setSoTimeout in nonblocking mode?

    Exactly the same!!!!
    "KimTaehwan " <neosuper@cyb er-r.com> wrote in message
    news:751c43b4.0 311151748.681cd [email protected] gle.com...[color=blue]
    > I want to be throw exception when one thread wait to read no data from
    > a remote source for long time.
    >
    > This can be done in pre-1.4 enviroment like the following.
    >
    > --------------------------------------------------------------------------[/color]
    -[color=blue]
    > Socket sock = new Sokcet("REMOTE_ Addr", "REMOTE_por t");
    > sock.setSoTimeo ut(10000);
    > InputStream in = sock.getInputSt ream();
    > in.read(); // If some data would not be read in 10000ms, exception
    > would be throwed..
    > --------------------------------------------------------------------------[/color]
    -[color=blue]
    >
    >
    > But in nio of 1.4, how?[/color]


    Comment

    • nos

      #3
      Re: setSoTimeout in nonblocking mode?

      don't you need a channel?

      "SPG" <steve.goodsell @nopoo.blueyond er.co.uk> wrote in message
      news:z15ub.2444 $rk1.22092966@n ews-text.cableinet. net...[color=blue]
      > Exactly the same!!!!
      > "KimTaehwan " <neosuper@cyb er-r.com> wrote in message
      > news:751c43b4.0 311151748.681cd [email protected] gle.com...[color=green]
      > > I want to be throw exception when one thread wait to read no data from
      > > a remote source for long time.
      > >
      > > This can be done in pre-1.4 enviroment like the following.
      > >[/color]
      >
      > --------------------------------------------------------------------------
      > -[color=green]
      > > Socket sock = new Sokcet("REMOTE_ Addr", "REMOTE_por t");
      > > sock.setSoTimeo ut(10000);
      > > InputStream in = sock.getInputSt ream();
      > > in.read(); // If some data would not be read in 10000ms, exception
      > > would be throwed..[/color]
      >
      > --------------------------------------------------------------------------
      > -[color=green]
      > >
      > >
      > > But in nio of 1.4, how?[/color]
      >
      >[/color]


      Comment

      Working...