Re: Timeout question on a socket thread
RVic wrote:
I have a thread that listens for a socket conection (and once the
connection is made, creates another thread to listen for another
connection, the former thread continues on to process the request). My
run() method is shown below (annotated for brevity).
I need to implement a timeout function between the time the connection
is established and the time it reads receives data (not the same thing
as ServerSocket.setSoTimeout() -- which is also implemented here btw.
Rather, I need to also herein put a maximum time limit it will wait
between the time the connection is establised and it receives a stream
of data).
My thoughts on how to implement this are with a timer. However, within
my run() method, I have a finally block necessary for cleanup. Thus,
if I am going to return from run(), I want to make sure to perform the
same cleanup. However, when I attempt this, inside the ActionListener
inside my timer, I get errors like:
Just set the timeout on the Socket returned when you do the
ServerSocket.accept(). If you don't receive any data by the timeout it
will throw a SocketException. This will have no effect on the ServerSocket.
--
Knute Johnson
email s/nospam/knute2009/
--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access