我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用base.NBNS。
def __init__(self, broadcast = True, listen_port = 0): """ Instantiate a NetBIOS instance, and creates a IPv4 UDP socket to listen/send NBNS packets. :param boolean broadcast: A boolean flag to indicate if we should setup the listening UDP port in broadcast mode :param integer listen_port: Specifies the UDP port number to bind to for listening. If zero, OS will automatically select a free port number. """ self.broadcast = broadcast self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) if self.broadcast: self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1) if listen_port: self.sock.bind(( '', listen_port ))