Hello,

I have a Windows client that tries to connect to an SSL server using the
following code :

   int status = ::connect( m_sock_fd,(sockaddr *)&m_addr,sizeof(m_addr));
   if (status == 0)
   {
      return true;
   }
   else
   {
            if (WSAGetLastError()== WSAEWOULDBLOCK)
            {
                  struct timeval tv;
                  tv.tv_sec = 20;
                  tv.tv_usec = 0;
                  fd_set myset;
                  FD_ZERO(&myset);
                  FD_SET(m_sock_fd, &myset);
                  status = select(m_sock_fd+1, NULL, &myset, NULL, &tv);
                  /*some other code  here*/
             }
             else if (WSAGetLastError() == WSAECONNREFUSED)
             {
                  return false;
             }
             else
             {
                /*some other code*/
             }
  }

The socket I am using is NONBLOCKING.

When my SSL server is up and running everything works as expected. When my
SSL server is down, my client times out in 20 seconds because
WSAGetLastError() returns WSAEWOULDBLOCK even when my server is not
listening!

I expect WSAGetLastError() to return WSAECONNREFUSED when my server is not
listening...

The problem I have with this is that my client is forced to wait for 20
seconds before giving up. I expect it to return immediately if the SSL
server is not listening...

Am I missing something? Thanks.

Reply via email to