[BUG] ssh_bind_listen() does not fail in windows when port is in use

2019-03-21 Thread Alberto Garcia
Hi, I see that ssh_bind_listen() does not fail in windows when the selected SSH_BIND_OPTIONS_BINDPORT is already taken by other listening process. Cheers. -- Alberto GarcĂ­a Illera GPG Public Key

Re: [BUG] ssh_bind_listen() does not fail in windows when port is in use

2019-03-21 Thread Alberto Garcia
Hi, So, I found this code in bind_socket() function: if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) < 0) { ssh_set_error(sshbind, SSH_FATAL, "Setting socket options failed: %s", str

Re: [BUG] ssh_bind_listen() does not fail in windows when port is in use

2019-03-21 Thread g4-lisz
On 22.03.19 00:15, Alberto Garcia wrote: > The socket has the SO_REUSEADDR so it does not fail when it is in use. > I don't know why that's set. Does anyone knows what is the intention > of it? Look here: https://stackoverflow.com/questions/577885/what-are-the-use-cases-of-so-reuseaddr I think it

Re: [BUG] ssh_bind_listen() does not fail in windows when port is in use

2019-03-21 Thread Alberto Garcia
I found a workaround. In my code I created a similar bind_socket() function: /* This is a copy to libssh bind_socket() but without setting SO_REUSEADDR so we can detect when an port is in use*/ socket_t SSHServer::bind_socket_non_reuse(ssh_bind sshbind, const char* hostname, int port) {

Re: [BUG] ssh_bind_listen() does not fail in windows when port is in use

2019-03-21 Thread g4-lisz
Ok, but in case of a restart, you have to wait quite a while. I don't know what's the equivalent of lock files in Windows. But maybe you wrap it as a service - then you can't start it twice at least. But still, another application could open a socket for the same address / port of course... > > T