def client(): io = SansIORW(encoding="utf-8") yield from io.write_struct("BBH4s", 4, 1, 123, b"\x00\x00\x00\x01") yield from io.write_c_string("yoba") yield from io.write_c_string("python.org") prefix, code, port, ipv4 = yield from io.read_struct("BBH4s") assert prefix == 0 assert code == 0x5a assert port == 0 assert ipv4 == b"\x00" * 4 yield from io.passthrough()
def client(): io = SansIORW(encoding="utf-8") yield from io.write_struct("BBH4s", 4, 1, 123, b"\x7f\x00\x00\x01") yield from io.write_c_string("yoba") prefix, code, port, ipv4 = yield from io.read_struct("BBH4s") assert prefix == 0 assert code == 0x5b assert port == 0 assert ipv4 == b"\x00" * 4 raise RuntimeError("connection failed")
def client(): io = SansIORW(encoding="utf-8") yield from io.write_struct("BBH4s", 4, 2, 123, b"\x7f\x00\x00\x01") yield from io.write_c_string("yoba") yield from io.passthrough()