[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

non-blocking mode is not working in 0.6.3


Hello, I'm trying to use libssh 0.6.3, but I found that I can not connect
to SSH server if I set it to non-blocking mode with:
  ssh_set_blocking(sess, 0);
The ssh_connect function always return SSH_AGAIN in non-blocking mode.
when I comment this line out, I can connect to SSH server correctly

Any idea of this?

Thanks


my code:
bool ssh_test(int fd,  port_t port, ip_t ip)
{

  ssh_session sess = ssh_new();
  if(sess == NULL){
    debug("fail in ssh_new\n");
    return false;
  }

  //set options
  ssh_set_blocking(sess, 0);
  ssh_options_set(sess, SSH_OPTIONS_FD, &fd);
  int ret = ssh_connect(sess);
  if(ret){
    debug("failed to connect to ssh %08lx:%d, ret = [%d].\n", ip, port,
ret);
    goto cleanup;
  }
  debug("ssh connect succeed, ret = [%d]\n", ret);

cleanup:
  if(sess)
    ssh_free(sess);
  if(fd != -1)
    close(fd);

  return true;
}

Follow-Ups:
Re: non-blocking mode is not working in 0.6.3Aris Adamantiadis <aris@xxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org