fix UDP server

This commit is contained in:
clowwindy 2014-10-31 21:59:22 +08:00
parent 4699de1dd9
commit efd45ddfc6

View file

@ -105,14 +105,14 @@ def pack_addr(address):
try: try:
r = socket.inet_pton(family, address) r = socket.inet_pton(family, address)
if family == socket.AF_INET6: if family == socket.AF_INET6:
return '\x04' + r return b'\x04' + r
else: else:
return '\x01' + r return b'\x01' + r
except (TypeError, ValueError, OSError, IOError): except (TypeError, ValueError, OSError, IOError):
pass pass
if len(address) > 255: if len(address) > 255:
address = address[:255] # TODO address = address[:255] # TODO
return '\x03' + chr(len(address)) + address return b'\x03' + chr(len(address)) + address
def parse_header(data): def parse_header(data):