コード例 #1
0
        internal void  SendChannelData(byte[] buf, int offset, int len)
        {
            try
            {
                if (state != CHANNEL_OPEN)
                {
                    throw new SSHException("The channel is closed", SSHException.CHANNEL_FAILURE);
                }

                if (len > 0)
                {
                    SSHPacket packet = connection.GetPacket();
                    packet.WriteByte((System.Byte)SSH_MSG_CHANNEL_DATA);
                    packet.WriteUINT32(remoteid);
                    packet.WriteBinaryString(buf, offset, len);

#if DEBUG
                    System.Diagnostics.Trace.WriteLine("Sending SSH_MSG_CHANNEL_DATA");
                    System.Diagnostics.Trace.WriteLine("Channelid=" + ChannelID);
#endif
                    connection.SendMessage(packet);
                }
            }
            catch (System.IO.IOException ex)
            {
                throw new SSHException(ex.Message, SSHException.INTERNAL_ERROR);
            }
        }