<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def listener(self, acceptor, wrapper):
 """ Listens for new connections to the manager's endpoint. Once a new connection is received, a UDPTendril object is generated for it and it is passed to the acceptor, which must initialize the state of the connection. If no acceptor is given, no new connections can be initialized. :param acceptor: If given, specifies a callable that will be called with each newly received UDPTendril; that callable is responsible for initial acceptance of the connection and for setting up the initial state of the connection. If not given, no new connections will be accepted by the UDPTendrilManager. :param wrapper: A callable taking, as its first argument, a socket.socket object. The callable must return a valid proxy for the socket.socket object, which will subsequently be used to communicate on the connection. """


        # OK, set up the socket
        sock = socket.socket(self.addr_family, socket.SOCK_DGRAM)

        with utils.SocketCloser(sock):
            # Bind to our endpoint
            sock.bind(self.endpoint)

            # Get the assigned port number
            self.local_addr = sock.getsockname()

            # Call any wrappers
            if wrapper:
                sock = wrapper(sock)

        # Senders need the socket, too...
        self._sock = sock
        self._sock_event.set()

        # OK, now go into the listening loop with an error threshold
        # of 10
        closer = utils.SocketCloser(sock, 10,
                                    ignore=[application.RejectConnection])
        while True:
            with closer:
                data, addr = sock.recvfrom(self.recv_bufsize)

                # Look up the tendril or create a new one
                try:
                    tend = self[(self.local_addr, addr)]
                except KeyError:
                    if not acceptor:
                        # Can't accept new connections
                        continue

                    # Construct a Tendril
                    tend = UDPTendril(self, self.local_addr, addr)

                    # Set up the application
                    tend.application = acceptor(tend)

                    # OK, let's track the tendril
                    self._track_tendril(tend)

                # We now have a tendril; process the received data
                try:
                    tend._recv_frameify(data)
                except Exception as exc:
                    # Close the Tendril
                    tend.close()

                    # Notify the application what happened
                    tend.closed(exc)