本文整理汇总了Python中twisted.protocols.policies.ProtocolWrapper.write方法的典型用法代码示例。如果您正苦于以下问题:Python ProtocolWrapper.write方法的具体用法?Python ProtocolWrapper.write怎么用?Python ProtocolWrapper.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.protocols.policies.ProtocolWrapper
的用法示例。
在下文中一共展示了ProtocolWrapper.write方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dataReceived
# 需要导入模块: from twisted.protocols.policies import ProtocolWrapper [as 别名]
# 或者: from twisted.protocols.policies.ProtocolWrapper import write [as 别名]
def dataReceived(self, data):
# type: (bytes) -> None
if not self.tlsStarted:
ProtocolWrapper.dataReceived(self, data)
return
self.encrypted += data
try:
while 1:
decryptedData = self._decrypt()
self._check()
encryptedData = self._encrypt()
ProtocolWrapper.write(self, encryptedData)
ProtocolWrapper.dataReceived(self, decryptedData)
if decryptedData == b'' and encryptedData == b'':
break
except BIO.BIOError as e:
# See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS
# for the error codes returned by SSL_get_verify_result.
e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0])
raise e
示例2: write
# 需要导入模块: from twisted.protocols.policies import ProtocolWrapper [as 别名]
# 或者: from twisted.protocols.policies.ProtocolWrapper import write [as 别名]
def write(self, data):
if not self.tlsStarted:
ProtocolWrapper.write(self, data)
else:
#Because of the FakeSocket, write operations are guaranteed to
#terminate immediately.
AsyncStateMachine.setWriteOp(self, data)
示例3: _clientHello
# 需要导入模块: from twisted.protocols.policies import ProtocolWrapper [as 别名]
# 或者: from twisted.protocols.policies.ProtocolWrapper import write [as 别名]
def _clientHello(self):
try:
# We rely on OpenSSL implicitly starting with client hello
# when we haven't yet established an SSL connection
encryptedData = self._encrypt(clientHello=1)
ProtocolWrapper.write(self, encryptedData)
self.helloDone = 1
except BIO.BIOError as e:
# See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS
# for the error codes returned by SSL_get_verify_result.
e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0])
raise e
示例4: write
# 需要导入模块: from twisted.protocols.policies import ProtocolWrapper [as 别名]
# 或者: from twisted.protocols.policies.ProtocolWrapper import write [as 别名]
def write(self, data):
if not self.tlsStarted:
ProtocolWrapper.write(self, data)
return
try:
encryptedData = self._encrypt(data)
ProtocolWrapper.write(self, encryptedData)
self.helloDone = 1
except M2Crypto.BIO.BIOError as e:
# See http://www.openssl.org/docs/apps/verify.html#DIAGNOSTICS
# for the error codes returned by SSL_get_verify_result.
e.args = (m2.ssl_get_verify_result(self.ssl._ptr()), e.args[0])
raise e
示例5: actuallyWrite
# 需要导入模块: from twisted.protocols.policies import ProtocolWrapper [as 别名]
# 或者: from twisted.protocols.policies.ProtocolWrapper import write [as 别名]
def actuallyWrite(self):
if self.writeLimit is None:
data = self.buf
self.buf = ''
else:
data = self.buf[:self.writeLimit]
self.buf = self.buf[self.writeLimit:]
ProtocolWrapper.write(self, data)
if data != '':
self.writesOutstanding = True
reactor.callLater(1, self.actuallyWrite)
else:
self.writesOutstanding = False
if self.loseConnectionWhenReady:
self.actuallyLoseConnection()
示例6: send
# 需要导入模块: from twisted.protocols.policies import ProtocolWrapper [as 别名]
# 或者: from twisted.protocols.policies.ProtocolWrapper import write [as 别名]
def send(self, data):
ProtocolWrapper.write(self.wrapper, data)
return len(data)