Source code for M2Crypto.SSL.timeout
"""Support for SSL socket timeouts.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved.
Copyright 2008 Heikki Toivonen. All rights reserved.
"""
__all__ = ['DEFAULT_TIMEOUT', 'timeout', 'struct_to_timeout', 'struct_size']
import struct
DEFAULT_TIMEOUT = 600 # type: int
[docs]class timeout:
def __init__(self, sec=DEFAULT_TIMEOUT, microsec=0):
# type: (int, int) -> None
self.sec = sec
self.microsec = microsec
[docs] def pack(self):
return struct.pack('ll', self.sec, self.microsec)
[docs]def struct_to_timeout(binstr):
# type: (bytes) -> timeout
(s, ms) = struct.unpack('ll', binstr)
return timeout(s, ms)
[docs]def struct_size():
# type: () -> int
return struct.calcsize('ll')