开发者

problem of using ssh_connect API in windows

I have tested a simple code using libssh on OS X and it worked simply f开发者_Python百科ind. But when I port this code on Windows7 using vc10 it doesn't work correctly. The ssh_connect API blocks and not progress any more.

The following code is part of the my test program.

#include <libssh/libssh.h>
...
int _tmain(..) 
{
  ssh_session session;

  session = ssh_new();
  if (session == NULL)
    exit(EXIT_FAILURE);

  ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
  int port = 1234;
  ssh_options_set(session, SSH_OPTIONS_PORT, &port); // <-block here !!!

  int rc = ssh_connect(session);
  if (rc != SSH_OK)
  {
    ...
  }
}

I downloaded include, lib and dll files from www.libssh.org no compile and link errors.

What's wrong with my code or do I miss something important?


Maybe it blocks cause the port is wrong? The timeout is 30 min by default iirc. libssh 0.6 will have better timeout handling.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜