clisocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
connection_id = 4497486125440
action = 0
transaction_id = 12345
print(transaction_id)
packet = struct.pack('>QLL', connection_id, action, transaction_id)
print(repr(packet))
clisocket.sendto(packet, ('tracker.istole.it', 80))
res = clisocket.recv(16)
action, transaction_id, connection_id = struct.unpack('>LLQ', res)
print(action)
print(transaction_id)
print(connection_id)
Choosing format in pack() using struct module in python