I'm currently working on a client that talk with a SSH server. Everything works well, but, because the server is quite slow to answer, I have to wait for it to send data. I have two choices, and I'd like to have your advice about what is the most efficient way to wait for the server.
Choice #1 :
while (!(ssh_channel_poll(*sshChannel,0)))
;
Choice #2 :
while (!(ssh_channel_poll(*sshChannel,0)))
sleep(1);
Both alternatives are undesirable. Normally, you would use a blocking read. I assume it looks something like this (since you say you are waiting for the server):
In this case, the
poll
is unnecessary. Just make sure the SSH connection is a blocking connection, and theread
function will wait until data is available if none is available when you call it.