def server(): io = SansIORW(encoding="utf-8") version, command, port, ipv4 = yield from io.read_struct("BBH4s") assert version == 4 assert command == 1 assert port == 123 assert ipv4 == b"\x00\x00\x00\xff" user_id = yield from io.read_c_string() assert user_id == "" host = yield from io.read_c_string() assert host == "python.org" yield from io.connect(host, port) yield from io.write_struct("BBH4s", 0, 0x5a, 0, b"\x00" * 4) yield from io.passthrough()
def server(): io = SansIORW(encoding="utf-8") version, command, port, ipv4 = yield from io.read_struct("BBH4s") assert version == 4 assert command == 1 assert port == 123 assert ipv4 == b"\x7f\x00\x00\x01" user_id = yield from io.read_c_string() assert user_id == "yoba" yield from io.connect(ipv4, port) yield from io.write_struct("BBH4s", 0, 0x5a, 666, b"\x00" * 4) yield from io.passthrough()