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

Re: non-blocking mode is not working in 0.6.3


Hi Aris,

Could you give me an example of using ssh_poll_ctx objects?

Thanks


On Mon, Aug 4, 2014 at 11:17 PM, Aris Adamantiadis <aris@xxxxxxxxxxxx>
wrote:

> Hi,
>
> When you enable the nonblocking mode, all libssh functions return
> SSH_AGAIN till there's something to read on the socket. What you see
> here is normal, you must either use the blocking mode or select() on the
> libssh fd, or use ssh_poll_ctx objects from libssh.
>
> Aris
>
> Le 2/08/14 01:49, Liang Qin a écrit :
> > 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;
> > }
> >
> >
>
>
>


-- 
Liang Qin CISSP |lqin@xxxxxxxxxx
Software Engineer
Qualys, Inc. | Continuous Security | www.qualys.com
<http://www.qualys.com/>
Direct: 650.801.7728 | Fax : 650.801.6149

Archive administrator: postmaster@lists.cynapses.org