hi all,
first i searched the internet and did not find something help me or i did not understand what they say. i have server client program the client send data to the server and the server reply i want if the client did not send data for 2 hours the server close the thread.
lena1990
-3
Junior Poster in Training
Recommended Answers
Jump to PostYou can use a java.util.Timer
When you receive anything from the user, cancel any existing Timer and start a new one with a 2 hour delay.
If the Timer's TimerTask ever runs it means 2 hours have expired without any input, so it can close the connection.
Jump to PostOK, here's little runnable demo code that wants you to keep typing lines of anything. If you don't enter a line for 2 secs it times out and exits.
If you read this code, in conjunction with the API doc, you should be able to write a version that fits …
All 7 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
lena1990
-3
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
lena1990
-3
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
lena1990
-3
Junior Poster in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.