/* Make a socket. */

I'm doing this.



  int sock = socket( AF_INET, SOCK_STREAM, 0 );
  if( sock < 0 ) {

  }
      
  /* Need to specify some timeouts. 
     The is a problem with some sites causing 
     this code to hang when negotiating. */

  setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof( tv ));
  setsockopt( sock, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof( tv ));

  /* Connect to the server. */

  struct sockaddr_in sa;
  memset( &sa, 0, sizeof( sa ));

  sa.sin_family = AF_INET;
  sa.sin_addr = addr;
  sa.sin_port = htons( port );

  err = connect( sock, (struct sockaddr*)&sa, sizeof( sa ));
  if( err < 0 ) {

  }
 
  /* We're connected with a server.
     Negotiate a SSL connection. */

  ssl = SSL_new( ctx );

  SSL_set_fd ( ssl, sock );

  err = SSL_connect( ssl );
  if( err < 0 ) {
        
  }







> Alice Joseph wrote:
> 
> Hi,
> 
> I am getting some problems with SSL_Connect.
> 
> 
> This is waht I do.
> 
> i.  get a socket
>      fd = socket(AF_INET, SOCK_STREAM, 0);
> 
> ii. connect to the remote host:port
>     connect(fd, (struct sockaddr *)&sa, sizeof(sa));
> 
> iii. Create a new SSL session
>     ssl = SSL_new(ctx);
> 
> iv. set the socket for this session
>    SSL_set_fd(ssl, fd);
> 
> v. Initiate an SSLConnection
>     SSL_connect(ssl);
> 
> This call doesn't return at times and 'gdb' shows it's in read()
> called by ssl_read().
> 
> How do I timeout this SSL_connect() call?
> 
> How should I go about it?
> 
> Thanks
> -alice
>

S/MIME Cryptographic Signature

Reply via email to