how to track Message Response time and retransmission
I am working on Client Server application.
There are lots of command exchanged between client server.There are certain command for which response time is 30sec,20 sec.
I am developing this application both windows and linux platform. Suppose client sents a coomand called "COMAND1" and expects respose "RESPONSE1" within 30 sec otherwise it will retransmits the command "COMAND1". I wanted to know best way to track and implement开发者_Python百科 this feature.
I am not well versed in linux. for windows I am thinking to have timer function.which will activated once the command is sent and if response message is not coming in proper time it will cause the system to retrasmit the command again.
1.Is this a right way to do this.
2.how can i implement it on linux.
Thanks,
You have a few options:
- Use alarms (i.e. signals) - if your granularity is seconds, this may be adequate
- If you can use a third-party library - such as boost, it will provide concepts such as dead line timers.
- RYO, with threads and select (or some such - e.g. pthread timed condition wait)
btw. IMHO, the right way is option 2, but that's my opinion, I'm sure someone else will select 1 or 3.
精彩评论