Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby套接字查找消息的发送和接收时间_Ruby_Sockets_Tcp_Udp - Fatal编程技术网

Ruby套接字查找消息的发送和接收时间

Ruby套接字查找消息的发送和接收时间,ruby,sockets,tcp,udp,Ruby,Sockets,Tcp,Udp,ruby中是否有一个预定义的套接字类函数,允许我记录消息发送和接收的时间 此时我正在发送或接收消息,然后立即记录时间。虽然这是工作,我想知道是否有人知道一个更好的方法 下面是我目前的做法。这是基于我必须编写的ClientTCP类。服务器以类似的方式布置 def send_mess @n.times do @client.print(@message) @sent_time_arr << (Time.now.to_f) slee

ruby中是否有一个预定义的套接字类函数,允许我记录消息发送和接收的时间

此时我正在发送或接收消息,然后立即记录时间。虽然这是工作,我想知道是否有人知道一个更好的方法

下面是我目前的做法。这是基于我必须编写的ClientTCP类。服务器以类似的方式布置

def send_mess
    @n.times do
        @client.print(@message)
        @sent_time_arr << (Time.now.to_f)

        sleep(1/@freq)

    end
    @client.close
    return @sent_time_arr
end
def send_mess
@n、 时代确实如此
@client.print(@message)

@很抱歉,使用标准套接字库无法做到这一点。您可以尝试覆盖socket类上的
read()
write()
方法,但您现在所做的似乎也在起作用