setSoTimeout in nonblocking mode?

K

KimTaehwan

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_port");
sock.setSoTimeout(10000);
InputStream in = sock.getInputStream();
in.read(); // If some data would not be read in 10000ms, exception
would be throwed..
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top