Timing
Challenge
Solution
import socket
import time
HOST = "10.242.0.1"
PORT = 10003
for i in range(100):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
start_at = time.time()
s.recv(1024)
s.send(b'0\n')
d = s.recv(1024)
if d.startswith(b'Error'):
n = int(d.split(b'was')[1].strip())
print(start_at, "=>", n)
# 1670952928.1638553 => 21
# ...
# 1670952928.6083567 => 21
# 1670952928.7483597 => 3
# ...
# 1670952929.2978578 => 3
# 1670952929.3879302 => 40Mis à jour