Esempio n. 1
0
 def client():
     io = SansIORW(encoding="utf-8")
     yield from io.write_struct("B", 5)
     yield from io.write_struct("BB", 1, 2)
     version, auth_method = yield from io.read_struct("BB")
     assert (version, auth_method) == (5, 2)
     yield from io.write_struct("B", 1)
     yield from io.write_pascal_string("yoba1")
     yield from io.write_pascal_string("foo")
     auth_version, retcode = yield from io.read_struct("BB")
     assert (auth_version, retcode) == (1, 1)
     yield from io.passthrough()
Esempio n. 2
0
 def client():
     io = SansIORW(encoding="utf-8")
     yield from io.write_struct("B", 5)
     yield from io.write_struct("BB", 1, 0)
     version, auth_method = yield from io.read_struct("BB")
     assert (version, auth_method) == (5, 0)
     yield from io.write_struct("4B", 5, 1, 0, 3)
     yield from io.write_pascal_string("python.org")
     yield from io.write_struct("H", 666)
     version, command, zero, address_type = yield from io.read_struct("4B")
     assert (version, command, zero, address_type) == (5, 0, 0, 1)
     ipv4, port = yield from io.read_struct("4sH")
     assert (ipv4, port) == (b"\x00" * 4, 0)
     yield from io.passthrough()