Logo Search packages:      
Sourcecode: znc version File versions  Download package

bool Csock::ConnectSSL ( const CS_STRING &  sBindhost = ""  )  [virtual]

Create the SSL connection

Parameters:
sBindhost the ip you want to bind to locally
Returns:
true on success

Definition at line 932 of file Csocket.cpp.

References Connect(), and SSLClientSetup().

Referenced by ConnectFD().

{
#ifdef HAVE_LIBSSL
      if ( m_iReadSock == -1 )
            if ( !Connect( sBindhost ) )
                  return( false );

      if ( !m_ssl )
            if ( !SSLClientSetup() )
                  return( false );

      bool bPass = true;

      if ( m_bBLOCK )
      {
#ifdef _WIN32
            u_long iOpts = 1;
            ioctlsocket( m_iReadSock, FIONBIO, &iOpts );
#else
            int fdflags = fcntl ( m_iReadSock, F_GETFL, 0);
            fcntl( m_iReadSock, F_SETFL, fdflags|O_NONBLOCK );
#endif /* _WIN32 */
      }

      int iErr = SSL_connect( m_ssl );
      if ( iErr != 1 )
      {
            int sslErr = SSL_get_error( m_ssl, iErr );

            if ( ( sslErr != SSL_ERROR_WANT_READ ) && ( sslErr != SSL_ERROR_WANT_WRITE ) )
                  bPass = false;
      } else
            bPass = true;

      if ( m_bBLOCK )
      {
            // unset the flags afterwords, rather then have connect block
#ifdef _WIN32
            u_long iOpts = 0;
            ioctlsocket( m_iReadSock, FIONBIO, &iOpts );
#else
            int fdflags = fcntl (m_iReadSock, F_GETFL, 0);
            fdflags &= ~O_NONBLOCK;
            fcntl( m_iReadSock, F_SETFL, fdflags );
#endif /* _WIN32 */

      }

      return( bPass );
#else
      return( false );
#endif /* HAVE_LIBSSL */
}


Generated by  Doxygen 1.6.0   Back to index