0 votes
by (190 points)

Hi, im trying to send bytes from client to server with using request.exec command and channel.send function but i couldnt figure it out how to get bytes on the server. Here is my code;

Client Code;

this.Channel = this.Client.Session.OpenSession();
this.Channel.RequestExec($"DDFCRTE {Path.GetFileName(item)} {tvGosterim.SelectedNode.Tag}");
byte[] dizi = File.ReadAllBytes(item);
this.Channel.Send(dizi, 0, dizi.Count());

Server Code;

private void Server_ShellCommand(object sender, ShellCommandEventArgs e)
{
    switch (e.Command)
    {
       case "DDFCRTE":
       break;
    }
}

1 Answer

0 votes
by (147k points)

If you need to process raw input stream bytes, you can use the approach described in the following forum post:

In your scenario, you don't need to execute an external, but the with using e.Action in ShellCommand event handler along with grabbing the raw input/output streams using SshConsole.GetInputStream() and SshConsole.GetOutputStream() would be suitable as well.

...