Net_SSH2::_close_channel PHP Méthode

_close_channel() public méthode

Net_SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server and for SFTP channels are presumably closed when the client disconnects. This functions is intended for SCP more than anything.
public _close_channel ( integer $client_channel, boolean $want_reply = false ) : boolean
$client_channel integer
$want_reply boolean
Résultat boolean
    function _close_channel($client_channel, $want_reply = false)
    {
        // see http://tools.ietf.org/html/rfc4254#section-5.3
        $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_EOF, $this->server_channels[$client_channel]));
        if (!$want_reply) {
            $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel]));
        }
        $this->channel_status[$client_channel] = NET_SSH2_MSG_CHANNEL_CLOSE;
        $this->curTimeout = 0;
        while (!is_bool($this->_get_channel_packet($client_channel))) {
        }
        if ($want_reply) {
            $this->_send_binary_packet(pack('CN', NET_SSH2_MSG_CHANNEL_CLOSE, $this->server_channels[$client_channel]));
        }
        if ($this->bitmap & NET_SSH2_MASK_SHELL) {
            $this->bitmap &= ~NET_SSH2_MASK_SHELL;
        }
    }

Usage Example

Exemple #1
0
 public function closeChannel()
 {
     $this->ssh->_close_channel(NET_SSH2_CHANNEL_EXEC);
 }