本文介绍了计时器和非阻塞套接字的处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要一个基于RTS的项目中的计时器实现,在该项目下,我需要执行以下操作:

1.这是一个基于套接字的项目,我正在其中发送并等待另一端的响应,该套接字是非阻塞套接字.

2.响应时间不确定,因此我们将最大响应计时器计算为5毫秒.我不能在这里使用"pselect",因为它是非阻塞套接字,也不能在其他情况下使用"usleep",否则实际进程将进入睡眠状态.

3.因此,我必须编写一个计时器,该计时器将在某个计时器处启动,并且必须在计时器到期时调用处理程序函数,但是如果在最大计时器持续时间响应之间,我们必须销毁该计时器并调用套接字处理程序函数.

4.时间和处理程序实现可能不是信号处理程序/生成器类型.

请帮助我,找到合适的方法或分享有帮助的资源.


问候,
Bisht

Hi All,

I need a timer implementation in my project which is RTS based, under which I need following:

1. It''s a socket based project in which I am sending and waiting for response from the other side, the socket is non-blocking socket.

2. The response time is not sure so we have calculated the max response timer as 5ms. I can''t use "pselect" here as it is non-blocking socket and also can''t use "usleep" other wise actual process will sleep.

3. So I have to write a timer which will started at certain timer and must call the handler function when the timer expires, but also if in between the max timer duration response comes we have to destroy the timer and call the socket handler function.

4. The time and handler implementation may or may not be of signal handler/generator type.

Please help me, either find the proper way to do it or share resources helpful for it.


Regards,
Bisht

推荐答案


这篇关于计时器和非阻塞套接字的处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 13:51