'Pretend to bind a UDP port and connect the given protocol to it.'

def listenUDP(self, port, protocol, interface='', maxPacketSize=8192):

    if (port == 0):
        while True:
            port = randrange(1, (2 ** 16))
            if (port not in self.udpPorts):
                break
    if (port in self.udpPorts):
        raise ValueError('Address    in    use')
    transport = MemoryDatagramTransport((interface, port), protocol, maxPacketSize)
    self.udpPorts[port] = transport
    protocol.makeConnection(transport)
    return transport
