本文整理汇总了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
示例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()
示例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)
示例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)
示例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
示例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)
示例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)