MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / __init__

Method __init__

pager_lib/nmb/NetBIOSProtocol.py:15–29  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected