Using TScSSHChannel to transfer binary data

Using TScSSHChannel to transfer binary data

Dear Friends,

This may be me having overlooked something obvious, for that I will apologize on beforehand.

I'm having a bit of a challenge with TScSshChannel.

I have built a small socketserver that accepts connections to a local listening socket and upon connect, use TScSshClient and TScSshChannel to establish a connection to a SSH server and use it to function as a proxy.

This all works beautifully.

I can connect to the local socket and connect to any network service exchanging ASCII data, such as a http webserver or a telnet server, this tests out fine.

Now, the issue I'm having is that it seems that when I connect to anything binary, this could be another SSH server, a TLS/SSL webserver or anything else communicating in binary non ASCII data, it seems as the data is not transferred correctly over the SSH channel.

I have tried both ReadBuffer/WriteBuffer and SSHStream.Read/SSHStream.Write, but the result ends up being the same..

Like this sample:
------------
(InBuffer is a TBytes)

ioctlsocket(TheSocket,fionread,BufSize);
SetLength(InBuffer,BufSize);
SocketResult := recv(TheSocket,InBuffer[0],BufSize,0);
if SocketResult <> SOCKET_ERROR then
begin
  DaSshChannel.SSHStream.Write(InBuffer[0],SocketResult);
end;
------------
 I have also tried "DaSshChannel.WriteBuffer(InBuffer[0],SocketResult);" but the result is the same.

Could someone please point me in the right direction as to transmit and receive binary data over the SSH Channel ?

 Respectfully

  Jimi