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


Python tcp.Server方法代码示例

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


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

示例1: createTransport

# 需要导入模块: from twisted.internet import tcp [as 别名]
# 或者: from twisted.internet.tcp import Server [as 别名]
def createTransport(self, skt, peer, data, protocol):
        """
        Create a TCP transport, from a socket object passed by the parent.
        """
        self._connectionCount += 1
        transport = Server(skt, protocol, peer, JustEnoughLikeAPort,
                           self._connectionCount, reactor)
        if data == 'SSL':
            if self.usingSocketFile:
                # Mark the transport as "secure", enough for getHostInfo() to
                # think so
                transport.getPeerCertificate = lambda _: None
                directlyProvides(transport, ISSLTransport)
            else:
                transport.startTLS(self.contextFactory)
        transport.startReading()
        return transport 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:19,代码来源:metafd.py

示例2: setUp

# 需要导入模块: from twisted.internet import tcp [as 别名]
# 或者: from twisted.internet.tcp import Server [as 别名]
def setUp(self):
        def fakefromfd(fd, addressFamily, socketType):
            return FakeSocket(self)

        def fakerecvfd(fd):
            return "not an fd", "not a description"

        def fakeclose(fd):
            ""
        def fakegetsockfam(fd):
            return AF_INET
        self.patch(sendfdport, 'recvfd', fakerecvfd)
        self.patch(sendfdport, 'fromfd', fakefromfd)
        self.patch(sendfdport, 'close', fakeclose)
        self.patch(sendfdport, 'getsockfam', fakegetsockfam)
        self.patch(metafd, 'InheritedPort', InheritedPortForTesting)
        self.patch(metafd, 'Server', ServerTransportForTesting)
        # This last stubbed out just to prevent dirty reactor warnings.
        self.patch(HTTPChannel, "callLater", lambda *a, **k: None)
        self.svc = ReportingHTTPService(None, None, None)
        self.svc.startService() 
开发者ID:apple,项目名称:ccs-calendarserver,代码行数:23,代码来源:test_metafd.py

示例3: __init__

# 需要导入模块: from twisted.internet import tcp [as 别名]
# 或者: from twisted.internet.tcp import Server [as 别名]
def __init__(self, *args, **kwargs):
        tcp.Server.__init__(self, *args, **kwargs)
        self.startTLS(self.server.ctxFactory) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:5,代码来源:ssl.py

示例4: __init__

# 需要导入模块: from twisted.internet import tcp [as 别名]
# 或者: from twisted.internet.tcp import Server [as 别名]
def __init__(self, sock, protocol, client, server, sessionno, reactor):
        _SendmsgMixin.__init__(self)
        tcp.Server.__init__(self, sock, protocol, (client, None), server, sessionno, reactor) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:5,代码来源:unix.py

示例5: _fromConnectedSocket

# 需要导入模块: from twisted.internet import tcp [as 别名]
# 或者: from twisted.internet.tcp import Server [as 别名]
def _fromConnectedSocket(cls, fileDescriptor, factory, reactor):
        """
        Create a new L{Server} based on an existing connected I{SOCK_STREAM}
        socket.

        Arguments are the same as to L{Server.__init__}, except where noted.

        @param fileDescriptor: An integer file descriptor associated with a
            connected socket.  The socket must be in non-blocking mode.  Any
            additional attributes desired, such as I{FD_CLOEXEC}, must also be
            set already.

        @return: A new instance of C{cls} wrapping the socket given by
            C{fileDescriptor}.
        """
        skt = socket.fromfd(fileDescriptor, socket.AF_UNIX, socket.SOCK_STREAM)
        protocolAddr = address.UNIXAddress(skt.getsockname())

        proto = factory.buildProtocol(protocolAddr)
        if proto is None:
            skt.close()
            return

        # FIXME: is this a suitable sessionno?
        sessionno = 0
        self = cls(skt, proto, skt.getpeername(), None, sessionno, reactor)
        self.repstr = "<%s #%s on %s>" % (
            self.protocol.__class__.__name__, self.sessionno, skt.getsockname())
        self.logstr = "%s,%s,%s" % (
            self.protocol.__class__.__name__, self.sessionno, skt.getsockname())
        proto.makeConnection(self)
        return self 
开发者ID:wistbean,项目名称:learn_python3_spider,代码行数:34,代码来源:unix.py

示例6: __init__

# 需要导入模块: from twisted.internet import tcp [as 别名]
# 或者: from twisted.internet.tcp import Server [as 别名]
def __init__(self, sock, protocol, client, server, sessionno, reactor):
        tcp.Server.__init__(self, sock, protocol, (client, None), server, sessionno, reactor) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:4,代码来源:unix.py

示例7: __init__

# 需要导入模块: from twisted.internet import tcp [as 别名]
# 或者: from twisted.internet.tcp import Server [as 别名]
def __init__(self, sock, protocol, client, server, sessionno):
        tcp.Server.__init__(self, sock, protocol, (client, None), server, sessionno) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:4,代码来源:unix.py


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