def __init__(<EOL>self,<EOL>sock,<EOL>default_window_size=DEFAULT_WINDOW_SIZE,<EOL>default_max_packet_size=DEFAULT_MAX_PACKET_SIZE,<EOL>gss_kex=False,<EOL>gss_deleg_creds=True,<EOL>):
self.active = False<EOL>self.hostname = None<EOL>if isinstance(sock, string_types):<EOL><INDENT>hl = sock.split("<STR_LIT::>", <NUM_LIT:1>)<EOL>self.hostname = hl[<NUM_LIT:0>]<EOL>if len(hl) == <NUM_LIT:1>:<EOL><INDENT>sock = (hl[<NUM_LIT:0>], <NUM_LIT>)<EOL><DEDENT>else:<EOL><INDENT>sock = (hl[<NUM_LIT:0>], int(hl[<NUM_LIT:1>]))<EOL><DEDENT><DEDENT>if type(sock) is tuple:<EOL><INDENT>hostname, port = sock<EOL>self.hostname = hostname<EOL>reason = "<STR_LIT>"<EOL>addrinfos = socket.getaddrinfo(<EOL>hostname, port, socket.AF_UNSPEC, socket.SOCK_STREAM<EOL>)<EOL>for family, socktype, proto, canonname, sockaddr in addrinfos:<EOL><INDENT>if socktype == socket.SOCK_STREAM:<EOL><INDENT>af = family<EOL>sock = socket.socket(af, socket.SOCK_STREAM)<EOL>try:<EOL><INDENT>retry_on_signal(lambda: sock.connect((hostname, port)))<EOL><DEDENT>except socket.error as e:<EOL><INDENT>reason = str(e)<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise SSHException(<EOL>"<STR_LIT>".format(hostname, reason)<EOL>)<EOL><DEDENT><DEDENT>threading.Thread.__init__(self)<EOL>self.setDaemon(True)<EOL>self.sock = sock<EOL>self.sock.settimeout(self._active_check_timeout)<EOL>self.packetizer = Packetizer(sock)<EOL>self.local_version = "<STR_LIT>" + self._PROTO_ID + "<STR_LIT:->" + self._CLIENT_ID<EOL>self.remote_version = "<STR_LIT>"<EOL>self.local_cipher = self.remote_cipher = "<STR_LIT>"<EOL>self.local_kex_init = self.remote_kex_init = None<EOL>self.local_mac = self.remote_mac = None<EOL>self.local_compression = self.remote_compression = None<EOL>self.session_id = None<EOL>self.host_key_type = None<EOL>self.host_key = None<EOL>self.use_gss_kex = gss_kex<EOL>self.gss_kex_used = False<EOL>self.kexgss_ctxt = None<EOL>self.gss_host = None<EOL>if self.use_gss_kex:<EOL><INDENT>self.kexgss_ctxt = GSSAuth("<STR_LIT>", gss_deleg_creds)<EOL>self._preferred_kex = self._preferred_gsskex + self._preferred_kex<EOL><DEDENT>self.kex_engine = None<EOL>self.H = None<EOL>self.K = None<EOL>self.initial_kex_done = False<EOL>self.in_kex = False<EOL>self.authenticated = False<EOL>self._expected_packet = tuple()<EOL>self.lock = threading.Lock()<EOL>self._channels = ChannelMap()<EOL>self.channel_events = {}  <EOL>self.channels_seen = {}  <EOL>self._channel_counter = <NUM_LIT:0><EOL>self.default_max_packet_size = default_max_packet_size<EOL>self.default_window_size = default_window_size<EOL>self._forward_agent_handler = None<EOL>self._x11_handler = None<EOL>self._tcp_handler = None<EOL>self.saved_exception = None<EOL>self.clear_to_send = threading.Event()<EOL>self.clear_to_send_lock = threading.Lock()<EOL>self.clear_to_send_timeout = <NUM_LIT><EOL>self.log_name = "<STR_LIT>"<EOL>self.logger = util.get_logger(self.log_name)<EOL>self.packetizer.set_log(self.logger)<EOL>self.auth_handler = None<EOL>self.global_response = None<EOL>self.completion_event = None<EOL>self.banner_timeout = <NUM_LIT:15><EOL>self.handshake_timeout = <NUM_LIT:15><EOL>self.auth_timeout = <NUM_LIT:30><EOL>self.server_mode = False<EOL>self.server_object = None<EOL>self.server_key_dict = {}<EOL>self.server_accepts = []<EOL>self.server_accept_cv = threading.Condition(self.lock)<EOL>self.subsystem_table = {}<EOL>
Create a new SSH session over an existing socket, or socket-like
object.  This only creates the `.Transport` object; it doesn't begin
the SSH session yet.  Use `connect` or `start_client` to begin a client
session, or `start_server` to begin a server session.

If the object is not actually a socket, it must have the following
methods:

- ``send(str)``: Writes from 1 to ``len(str)`` bytes, and returns an
  int representing the number of bytes written.  Returns
  0 or raises ``EOFError`` if the stream has been closed.
- ``recv(int)``: Reads from 1 to ``int`` bytes and returns them as a
  string.  Returns 0 or raises ``EOFError`` if the stream has been
  closed.
- ``close()``: Closes the socket.
- ``settimeout(n)``: Sets a (float) timeout on I/O operations.

For ease of use, you may also pass in an address (as a tuple) or a host
string as the ``sock`` argument.  (A host string is a hostname with an
optional port (separated by ``":"``) which will be converted into a
tuple of ``(hostname, port)``.)  A socket will be connected to this
address and used for communication.  Exceptions from the ``socket``
call may be thrown in this case.

.. note::
    Modifying the the window and packet sizes might have adverse
    effects on your channels created from this transport. The default
    values are the same as in the OpenSSH code base and have been
    battle tested.

:param socket sock:
    a socket or socket-like object to create the session over.
:param int default_window_size:
    sets the default window size on the transport. (defaults to
    2097152)
:param int default_max_packet_size:
    sets the default max packet size on the transport. (defaults to
    32768)

.. versionchanged:: 1.15
    Added the ``default_window_size`` and ``default_max_packet_size``
    arguments.