[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Non-blocking Connect
[Thread Prev] | [Thread Next]
- Subject: RE: Non-blocking Connect
- From: Saju Panikulam <spanikulam@xxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Tue, 30 May 2017 12:48:34 +0000
- To: "libssh@xxxxxxxxxx" <libssh@xxxxxxxxxx>
Should not counter be checked against some give up now maximum? -----Original Message----- From: Jason Curl [mailto:jason@xxxxxxxxxxxxxxxxxxxxxxxx] Sent: Tuesday, May 30, 2017 2:59 AM To: libssh@xxxxxxxxxx Subject: Non-blocking Connect Hello, I'm trying non-blocking mode on master (dated 26th April) and as a test I'm connected to localhost where no server is running. The docs say to call connect() again after SSH_AGAIN, which I'm doing. As I know there is no server, I'd expect at some time the connection to timeout. But it doesn't. Is this a known bug in libssh.org? The reason why I'm using a non-blocking connect is to have the ability to abort it with .NET without memory leaks, putting a blocking connect on a thread and killing that thread means any internal memory allocated by libssh.org won't be freed. To give you an idea of the code I'm using: NativeMethods.ssh_set_blocking(m_Session, false); bool connected = false; int counter = 0; while (!connected) { SshResult crc = (SshResult)NativeMethods.ssh_connect(m_Session); if (crc == SshResult.SSH_OK) { Console.WriteLine("Connected"); connected = true; continue; } if (crc == SshResult.SSH_AGAIN) { Console.WriteLine("Busy {0}", counter++); System.Threading.Thread.Sleep(250); continue; } if (crc != SshResult.SSH_OK) { string message = string.Format("Cannot connect: {0} ({1})", GetError(), GetErrorCode()); throw new InvalidOperationException(message); } } If I have blocking mode, the connection fails after about 6 seconds: "Cannot connect: Timeout connecting to 127.0.0.1 (2)" I would have expected nonblocking mode to also eventually return an error with the same reason. Any help would be appreciated. Regards, Jason.
Non-blocking Connect | Jason Curl <jason@xxxxxxxxxxxxxxxxxxxxxxxx> |