Logo Search packages:      
Sourcecode: paramiko version File versions  Download package

def paramiko::transport::Transport::open_channel (   self,
  kind,
  dest_addr = None,
  src_addr = None 
)

Request a new channel to the server.  L{Channel}s are socket-like
objects used for the actual transfer of data across the session.
You may only request a channel after negotiating encryption (using
L{connect} or L{start_client}) and authenticating.

@param kind: the kind of channel requested (usually C{"session"},
    C{"forwarded-tcpip"} or C{"direct-tcpip"}).
@type kind: str
@param dest_addr: the destination address of this port forwarding,
    if C{kind} is C{"forwarded-tcpip"} or C{"direct-tcpip"} (ignored
    for other channel types).
@type dest_addr: (str, int)
@param src_addr: the source address of this port forwarding, if
    C{kind} is C{"forwarded-tcpip"} or C{"direct-tcpip"}.
@type src_addr: (str, int)
@return: a new L{Channel} on success, or C{None} if the request is
    rejected or the session ends prematurely.
@rtype: L{Channel}

Definition at line 572 of file transport.py.

00572                                                                :
        """
        Request a new channel to the server.  L{Channel}s are socket-like
        objects used for the actual transfer of data across the session.
        You may only request a channel after negotiating encryption (using
        L{connect} or L{start_client}) and authenticating.

        @param kind: the kind of channel requested (usually C{"session"},
            C{"forwarded-tcpip"} or C{"direct-tcpip"}).
        @type kind: str
        @param dest_addr: the destination address of this port forwarding,
            if C{kind} is C{"forwarded-tcpip"} or C{"direct-tcpip"} (ignored
            for other channel types).
        @type dest_addr: (str, int)
        @param src_addr: the source address of this port forwarding, if
            C{kind} is C{"forwarded-tcpip"} or C{"direct-tcpip"}.
        @type src_addr: (str, int)
        @return: a new L{Channel} on success, or C{None} if the request is
            rejected or the session ends prematurely.
        @rtype: L{Channel}
        """
        chan = None
        if not self.active:
            # don't bother trying to allocate a channel
            return None
        self.lock.acquire()
        try:
            chanid = self.channel_counter
            while self.channels.has_key(chanid):
                self.channel_counter = (self.channel_counter + 1) & 0xffffff
                chanid = self.channel_counter
            self.channel_counter = (self.channel_counter + 1) & 0xffffff
            m = Message()
            m.add_byte(chr(MSG_CHANNEL_OPEN))
            m.add_string(kind)
            m.add_int(chanid)
            m.add_int(self.window_size)
            m.add_int(self.max_packet_size)
            if (kind == 'forwarded-tcpip') or (kind == 'direct-tcpip'):
                m.add_string(dest_addr[0])
                m.add_int(dest_addr[1])
                m.add_string(src_addr[0])
                m.add_int(src_addr[1])
            self.channels[chanid] = chan = Channel(chanid)
            self.channel_events[chanid] = event = threading.Event()
            self.channels_seen[chanid] = True
            chan._set_transport(self)
            chan._set_window(self.window_size, self.max_packet_size)
        finally:
            self.lock.release()
        self._send_user_message(m)
        while 1:
            event.wait(0.1);
            if not self.active:
                return None
            if event.isSet():
                break
        try:
            self.lock.acquire()
            if not self.channels.has_key(chanid):
                chan = None
        finally:
            self.lock.release()
        return chan

    def open_sftp_client(self):


Generated by  Doxygen 1.6.0   Back to index