def recv(self, block=True):
    '\n        Read data from socket.\n\n        :returns: bytestring containing received data.\n        '
    flags = 0
    if (not block):
        flags = MSG_DONTWAIT
    buf = recv_all(self.sock, (self.COOKIE_LEN + 5), flags)
    if (not buf):
        return (None, None)
    (cookie, addr_type, packet_len) = struct.unpack('!8sBI', buf)
    if (cookie != self.COOKIE):
        raise SCIONIOError('Dispatcher socket out of sync')
    port_len = 0
    if (addr_type != AddrType.NONE):
        port_len = 2
    addr_len = haddr_get_type(addr_type).LEN
    buf = recv_all(self.sock, ((addr_len + port_len) + packet_len), 0)
    if (addr_len > 0):
        addr = buf[:addr_len]
        port = struct.unpack('!H', buf[addr_len:(addr_len + port_len)])
        sender = (str(ipaddress.ip_address(addr)), port)
    else:
        addr = ''
        port = 0
        sender = (None, None)
    packet = buf[(addr_len + port_len):]
    return (packet, sender)
Read data from socket.

:returns: bytestring containing received data.
def recv(self, block=True):
    '\n        Read data from socket.\n\n        :returns: bytestring containing received data.\n        '
    flags = 0
    if (not block):
        flags = MSG_DONTWAIT
    buf = recv_all(self.sock, (self.COOKIE_LEN + 5), flags)
    if (not buf):
        return (None, None)
    (cookie, addr_type, packet_len) = struct.unpack('!8sBI', buf)
    if (cookie != self.COOKIE):
        raise SCIONIOError('Dispatcher socket out of sync')
    port_len = 0
    if (addr_type != AddrType.NONE):
        port_len = 2
    addr_len = haddr_get_type(addr_type).LEN
    buf = recv_all(self.sock, ((addr_len + port_len) + packet_len), 0)
    if (addr_len > 0):
        addr = buf[:addr_len]
        port = struct.unpack('!H', buf[addr_len:(addr_len + port_len)])
        sender = (str(ipaddress.ip_address(addr)), port)
    else:
        addr = 
        port = 0
        sender = (None, None)
    packet = buf[(addr_len + port_len):]
    return (packet, sender)