本文整理汇总了Python中twisted.internet.interfaces.IReactorFDSet方法的典型用法代码示例。如果您正苦于以下问题:Python interfaces.IReactorFDSet方法的具体用法?Python interfaces.IReactorFDSet怎么用?Python interfaces.IReactorFDSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.internet.interfaces
的用法示例。
在下文中一共展示了interfaces.IReactorFDSet方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorFDSet [as 别名]
def __init__(self, port, proto, interface='', maxPacketSize=8192, reactor=None):
"""
@param port: A port number on which to listen.
@type port: L{int}
@param proto: A C{DatagramProtocol} instance which will be
connected to the given C{port}.
@type proto: L{twisted.internet.protocol.DatagramProtocol}
@param interface: The local IPv4 or IPv6 address to which to bind;
defaults to '', ie all IPv4 addresses.
@type interface: L{str}
@param maxPacketSize: The maximum packet size to accept.
@type maxPacketSize: L{int}
@param reactor: A reactor which will notify this C{Port} when
its socket is ready for reading or writing. Defaults to
L{None}, ie the default global reactor.
@type reactor: L{interfaces.IReactorFDSet}
"""
base.BasePort.__init__(self, reactor)
self.port = port
self.protocol = proto
self.maxPacketSize = maxPacketSize
self.interface = interface
self.setLogStr()
self._connectedAddr = None
self._setAddressFamily()
示例2: _fromListeningDescriptor
# 需要导入模块: from twisted.internet import interfaces [as 别名]
# 或者: from twisted.internet.interfaces import IReactorFDSet [as 别名]
def _fromListeningDescriptor(cls, reactor, fd, addressFamily, protocol,
maxPacketSize):
"""
Create a new L{Port} based on an existing listening
I{SOCK_DGRAM} socket.
@param reactor: A reactor which will notify this L{Port} when
its socket is ready for reading or writing. Defaults to
L{None}, ie the default global reactor.
@type reactor: L{interfaces.IReactorFDSet}
@param fd: An integer file descriptor associated with a listening
socket. The socket must be in non-blocking mode. Any additional
attributes desired, such as I{FD_CLOEXEC}, must also be set already.
@type fd: L{int}
@param addressFamily: The address family (sometimes called I{domain}) of
the existing socket. For example, L{socket.AF_INET}.
@param addressFamily: L{int}
@param protocol: A C{DatagramProtocol} instance which will be
connected to the C{port}.
@type proto: L{twisted.internet.protocol.DatagramProtocol}
@param maxPacketSize: The maximum packet size to accept.
@type maxPacketSize: L{int}
@return: A new instance of C{cls} wrapping the socket given by C{fd}.
@rtype: L{Port}
"""
port = socket.fromfd(fd, addressFamily, cls.socketType)
interface = port.getsockname()[0]
self = cls(None, protocol, interface=interface, reactor=reactor,
maxPacketSize=maxPacketSize)
self._preexistingSocket = port
return self