Instantiate a NBNSProtocol instance. This automatically calls reactor.listenUDP method to start listening for incoming packets, so you **must not** call the listenUDP method again. :param boolean broadcast: A boolean flag to indicate if we should setup the listening UDP po
(self, broadcast = True, listen_port = 0)
| 13 | log = logging.getLogger('NMB.NBNSProtocol') |
| 14 | |
| 15 | def __init__(self, broadcast = True, listen_port = 0): |
| 16 | """ |
| 17 | Instantiate a NBNSProtocol instance. |
| 18 | |
| 19 | This automatically calls reactor.listenUDP method to start listening for incoming packets, so you **must not** call the listenUDP method again. |
| 20 | |
| 21 | :param boolean broadcast: A boolean flag to indicate if we should setup the listening UDP port in broadcast mode |
| 22 | :param integer listen_port: Specifies the UDP port number to bind to for listening. If zero, OS will automatically select a free port number. |
| 23 | """ |
| 24 | self.broadcast = broadcast |
| 25 | self.pending_trns = { } # TRN ID -> ( expiry_time, name, Deferred instance ) |
| 26 | self.transport = reactor.listenUDP(listen_port, self) |
| 27 | if self.broadcast: |
| 28 | self.transport.getHandle().setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) |
| 29 | reactor.callLater(1, self.cleanupPendingTrns) |
| 30 | |
| 31 | def datagramReceived(self, data, from_info): |
| 32 | host, port = from_info |
nothing calls this directly
no outgoing calls
no test coverage detected