That's what I was going to do too, but under Win32 you can't set the
timeouts. SO_RCVTIMEO and SO_SNDTIMEO can only be used with getsockopt, not
setsockopt. Good solution under linux, just not Win32. Anyone know of a
portable way to do it?
-Sean
---
Celtech Software Making advanced software easy and fun to use
www.celsoft.com [EMAIL PROTECTED]
818-347-2875
----- Original Message -----
From: Dennis Glatting <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, December 15, 1999 7:45 PM
Subject: Re: How to timeout a SSL_connect?
>
> /* 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
> >
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]