diff -urb libssh2-0.11/src/session.c libssh2-0.11-jmk/src/session.c --- libssh2-0.11/src/session.c 2005-06-27 17:24:29.000000000 -0500 +++ libssh2-0.11-jmk/src/session.c 2005-11-10 20:27:34.000000000 -0600 @@ -95,12 +95,19 @@ { char banner[256]; int banner_len = 0; + int wait_count = 0; while ((banner_len < sizeof(banner)) && ((banner_len == 0) || (banner[banner_len-1] != '\n'))) { char c = '\0'; int ret; + wait_count++; + + /* If server is not responding, don't wait in loop forever */ + if (wait_count > 1000) + return 1; + ret = recv(session->socket_fd, &c, 1, LIBSSH2_SOCKET_RECV_FLAGS(session)); if ((ret < 0) && (ret != EAGAIN)) {