当前位置: 首页>>代码示例>>Python>>正文


Python base.BasePort方法代码示例

本文整理汇总了Python中twisted.internet.base.BasePort方法的典型用法代码示例。如果您正苦于以下问题:Python base.BasePort方法的具体用法?Python base.BasePort怎么用?Python base.BasePort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.base的用法示例。


在下文中一共展示了base.BasePort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: connectionLost

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def connectionLost(self, reason):
        """
        Cleans up the socket.
        """
        self._logConnectionLostMsg()
        self._realPortNumber = None

        base.BasePort.connectionLost(self, reason)
        self.connected = False
        self._closeSocket(True)
        del self.socket
        del self.fileno

        try:
            self.factory.doStop()
        finally:
            self.disconnecting = False 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:19,代码来源:tcp.py

示例2: connectionLost

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def connectionLost(self, reason):
        """
        Cleans up the socket.
        """
        self._logConnectionLostMsg()
        self._realPortNumber = None

        base.BasePort.connectionLost(self, reason)
        self.connected = False
        self._closeSocket()
        del self.socket
        del self.fileno

        try:
            self.factory.doStop()
        finally:
            self.disconnecting = False 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:19,代码来源:tcp.py

示例3: connectionLost

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def connectionLost(self, reason=None):
        """Cleans up my socket.
        """
        log.msg('(Port %s Closed)' % self._realPortNumber)
        self._realPortNumber = None
        base.BasePort.connectionLost(self, reason)
        if hasattr(self, "protocol"):
            # we won't have attribute in ConnectedPort, in cases
            # where there was an error in connection process
            self.protocol.doStop()
        self.connected = 0
        self.socket.close()
        del self.socket
        del self.fileno
        if hasattr(self, "d"):
            self.d.callback(None)
            del self.d 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:19,代码来源:udp.py

示例4: __init__

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [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() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:31,代码来源:udp.py

示例5: connectionLost

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def connectionLost(self, reason=None):
        """
        Cleans up my socket.
        """
        log.msg('(UDP Port %s Closed)' % self._realPortNumber)
        self._realPortNumber = None
        self.maxThroughput = -1
        base.BasePort.connectionLost(self, reason)
        self.protocol.doStop()
        self.socket.close()
        del self.socket
        del self.fileno
        if hasattr(self, "d"):
            self.d.callback(None)
            del self.d 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:17,代码来源:udp.py

示例6: __init__

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def __init__(self, port, factory, backlog=50, interface='', reactor=None):
        """Initialize with a numeric port to listen on.
        """
        base.BasePort.__init__(self, reactor=reactor)
        self.port = port
        self.factory = factory
        self.backlog = backlog
        if abstract.isIPv6Address(interface):
            self.addressFamily = socket.AF_INET6
            self._addressType = address.IPv6Address
        self.interface = interface 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:13,代码来源:tcp.py

示例7: createInternetSocket

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def createInternetSocket(self):
        s = base.BasePort.createInternetSocket(self)
        if platformType == "posix" and sys.platform != "cygwin":
            s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        return s 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:7,代码来源:tcp.py

示例8: test_listenFailure

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def test_listenFailure(self):
        """
        L{IReactorUNIX.listenUNIX} raises L{CannotListenError} if the
        underlying port's createInternetSocket raises a socket error.
        """
        def raiseSocketError(self):
            raise error('FakeBasePort forced socket.error')

        self.patch(base.BasePort, "createInternetSocket", raiseSocketError)
        reactor = self.buildReactor()
        with self.assertRaises(CannotListenError):
            reactor.listenUNIX('not-used', ServerFactory()) 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:14,代码来源:test_unix.py

示例9: _check_valid_port

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def _check_valid_port(self, port):
        """Various Port object validity checks. Raise a ValueError."""
        if not isinstance(port, BasePort):
            raise ValueError("expected a Port, got %r"%(port))
        
        if not port.connected:
            raise ValueError("Port %r is not listening"%(port))
        
        loc_addr = port.getHost()
        if loc_addr.port == 0:
            raise ValueError("Port %r has port number of 0"%(port)) 
开发者ID:donSchoe,项目名称:p2pool-n,代码行数:13,代码来源:portmapper.py

示例10: __init__

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def __init__(self, port, proto, interface='', maxPacketSize=8192, reactor=None):
        """
        Initialize with a numeric port to listen on.
        """
        base.BasePort.__init__(self, reactor)
        self.port = port
        self.protocol = proto
        self.maxPacketSize = maxPacketSize
        self.interface = interface
        self.setLogStr()
        self._connectedAddr = None 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:13,代码来源:udp.py

示例11: connectionLost

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def connectionLost(self, reason=None):
        """
        Cleans up my socket.
        """
        log.msg('(Port %s Closed)' % self._realPortNumber)
        self._realPortNumber = None
        base.BasePort.connectionLost(self, reason)
        self.protocol.doStop()
        self.connected = 0
        self.socket.close()
        del self.socket
        del self.fileno
        if hasattr(self, "d"):
            self.d.callback(None)
            del self.d 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:17,代码来源:udp.py

示例12: __init__

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def __init__(self, port, factory, backlog=50, interface='', reactor=None):
        """Initialize with a numeric port to listen on.
        """
        base.BasePort.__init__(self, reactor=reactor)
        self.port = port
        self.factory = factory
        self.backlog = backlog
        self.interface = interface 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:10,代码来源:tcp.py

示例13: __init__

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def __init__(self, interface, proto, maxPacketSize=8192, reactor=None):
        if components.implements(proto, ethernet.IEthernetProtocol):
            self.ethernet = 1
        else:
            self.ethernet = 0
            assert components.implements(proto, ip.IIPProtocol) # XXX: fix me
        base.BasePort.__init__(self, reactor)
        self.interface = interface
        self.protocol = proto
        self.maxPacketSize = maxPacketSize
        self.setLogStr() 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:13,代码来源:tuntap.py

示例14: connectionLost

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def connectionLost(self, reason=None):
        """Cleans up my socket.
        """
        log.msg('(Tuntap %s Closed)' % self.interface)
        base.BasePort.connectionLost(self, reason)
        if hasattr(self, "protocol"):
            # we won't have attribute in ConnectedPort, in cases
            # where there was an error in connection process
            self.protocol.doStop()
        self.connected = 0
        os.close(self.fd)
        del self.fd 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:14,代码来源:tuntap.py

示例15: __init__

# 需要导入模块: from twisted.internet import base [as 别名]
# 或者: from twisted.internet.base import BasePort [as 别名]
def __init__(self, port, proto, interface='', maxPacketSize=8192, reactor=None):
        """Initialize with a numeric port to listen on.
        """
        base.BasePort.__init__(self, reactor)
        self.port = port
        self.protocol = proto
        self.maxPacketSize = maxPacketSize
        self.interface = interface
        self.setLogStr()
        self._connectedAddr = None 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:12,代码来源:udp.py


注:本文中的twisted.internet.base.BasePort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。