在再次发送之前增加延迟到接收到的数据? [英] add delay to received data before send it again?

查看:112
本文介绍了在再次发送之前增加延迟到接收到的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想知道如何在通过网络再次发送之前向某些接收到的原始数据添加延迟(例如:200ms)?

在此先感谢您的帮助. :-D :-D

Hi everyone,

I want to know how can I add a delay (ex:200ms) to some received raw data before send it again through the network?

thanks in advance for your help. :-D :-D

推荐答案

这实际上取决于您要实现的目标.您想要执行此类操作的特殊原因是什么?
您是否必须为所有接收到的数据添加相同的延迟?

一种方法是创建一种队列,在该队列中您将数据推入其中,然后一个单独的线程从队列中弹出数据(使用某种调度).这样,您将等待委托给了单独的线程,以免阻塞您的处理线程.
It really depends on what you are trying to achieve. What is the particular reason you want to do something like that ?
Do you have to add the same delay for all data received ?

One approach would be to create a kind of queue where you push data in and a separate thread pops data from the queue (using a kind of scheduling). This way, you delegate the wait to a separate thread in order not to block your processing thread.


这篇关于在再次发送之前增加延迟到接收到的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆