Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write a timer to monitor a server?

Status
Not open for further replies.

lichtjiang

Programmer
Feb 26, 2007
39
0
0
US
I have a program that uses socket in this way: Client A has a socket connection to Server B. A sends some data to B. B processes data and return results to A.

However, sometimes, B might take too long to process data and in such a case, for efficiency consideration, A would expect B to simply terminate the processing and notify A with a failure message other than waiting for ever. So, in B, I would like to write a timer T. It starts timing when B receives data from A. It would timeout if B spends some predefined length of time on processing the data. Then B will stop and sends some message back to A to let it know.

Any idea or suggestions for doing this? Thanks!
 
Rather than having B send back a timeout error, why not simply discard the transaction? A could send some data to B along with the max time that it is willing to wait for the answer. B can either respond immediately and say it won't process it, or try to do it and then either send it before the elapsed time, or throw away the data and get back to doing whatever it normally does. If at any time during the data processing B encounters an error and cannot continue, if the time hasn't elapsed then it should send a message to A indicating that it can't process the data... That way A doesn't have to wait until the timeout before trying a different server or doing whatever it does when it can't get the job done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top