當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。