1

I have tested a simple code using libssh on OS X and it worked simply find. 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?

yielding
  • 77
  • 1
  • 7

1 Answers1

1

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

asn
  • 798
  • 9
  • 17
  • Thank you asn. It's my mistake. In my ../etc/hosts file, the mapping of localhost and 127.0.0.1 was commented out. I changed "localhost" to "127.0.0.1" in my source code and everything looks okay. Thanks for your tip of timeout setting. – yielding Sep 26 '11 at 23:50