Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import binascii
- import socket
- import threading
- import random
- times = []
- # connectivitycheck.gstatic.com, nuq04s42
- host = '142.250.191.35'
- message = 'GET /generate_204 HTTP/1.1\r\nHost: connectivitycheck.gstatic.com:80\r\nConnection: close\r\n\r\n'
- message = message.encode()
- script_start = time.time()
- def send_and_measure():
- send_start = time.time()
- sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- sock.settimeout(1)
- try:
- sock.connect((host, 80))
- sock.send(message)
- sock.recvfrom(4096)
- except:
- pass
- finally:
- sock.close()
- now = time.time()
- pair = (now - script_start, now - send_start)
- print(*pair)
- times.append(pair)
- for i in range(10000):
- threading.Thread(target=send_and_measure).start()
- time.sleep(0.01)
Advertisement
Add Comment
Please, Sign In to add comment