def tos_recvfrom(self, bufsize=512):
"""Mimic the behavior of socket.recvfrom() with special behavior.
Args:
bufsize: (int) number of bytes to read from socket
It's not advisable to change this.
Returns:
(UdpData) namedtuple containing timestamps
"""
try:
data, addr = self.recvfrom(bufsize)
rcvd = time.time() * 1000
results = UdpData._make(struct.unpack(self.FORMAT, data))
rtt = rcvd - results.sent
return results._replace(rcvd=rcvd, rtt=rtt, lost=False)
except socket.timeout:
logging.debug('Timed out after {}s waiting to receive'.format(
self.gettimeout()))
return UdpData(self.SIGNATURE, self._tos, 0, 0, 0, True)
评论列表
文章目录