This is a multi-part message in MIME format.

------_=_NextPart_001_01C85922.09D76353
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi, all:
=20
Wondering if anybody has done something related this and give me some
suggestions.=20
=20
I am using OpenSsl library to do connection to a port. OpenSSL doesn't
provide a configurable timeout for BIO_do_connect. It is relying on the
underlying OS connection. If the port is unreachable, it will take about
2.5 mins to timeout, just like what telnet does to a port. Looks like
the only way to do a non-blocking IO is to use select or poll. I made
read/write work after the connection is established.=20
Now the problem is before the connection is established. Select is based
on the file descriptor. Looks like I can't get the file descriptor
before the connect. FD_SET(BIO_get_fd(conn, &c), &rfds) BIO_get_fd
returns null. what did I do wrong?
=20
Thanks in advance!
=20
-Yolanda
=20
Here is the code snippet:
=20
conn =3D BIO_new_connect(const_cast(svrPort.GetString()));
if(!conn)
{ return; }
=20
/* Configure the BIO as a non-blocking one */
BIO_set_nbio(conn, 1);
//select on read
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
int c =3D 0;
FD_SET(BIO_get_fd(conn, &c), &rfds);
//wait up to five seconds
tv.tv_sec =3D 5;
tv.tv_usec =3D 0;
=20
int retval =3D select(BIO_get_fd(conn, &c)+1, &rfds, NULL, NULL, =
&tv);
if(retval =3D=3D -1)
{
return;
}
BIO_do_connect(conn);


------_=_NextPart_001_01C85922.09D76353
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable



charset=3Dus-ascii">





Hi,=20
all:

class=3D375083115-17012008> 

class=3D375083115-17012008>Wondering if anybody=20
has done something related this and give me some suggestions.=20

class=3D375083115-17012008> 

I am =
using OpenSsl=20
library to do connection to a port. OpenSSL doesn't provide a =
configurable=20
timeout for BIO_do_connect. It is relying on the underlying OS =
connection. If=20
the port is unreachable, it will take about 2.5 mins to timeout, just =
like=20
what telnet does to a port. Looks like the only way to do a =
non-blocking IO=20
is to use select or poll. I made read/write work after the =
connection is=20
established.

Now =
the problem is=20
before the connection is established. Select is based on the file =
descriptor.=20
Looks like I can't get the file descriptor before the =
connect.  class=3D375083115-17012008> FD_SET(BIO_get_fd(conn, &c), =
&rfds)=20
BIO_get_fd returns null. what did I do wrong?

class=3D375083115-17012008> 

class=3D375083115-17012008>Thanks in advance!

class=3D375083115-17012008> 

class=3D375083115-17012008>-Yolanda

class=3D375083115-17012008> 

Here =
is the code=20
snippet:

class=3D375083115-17012008> face=3DArial size=3D2> class=3D375083115-17012008> size=3D2> 

conn =
=3D=20
BIO_new_connect(const_cast<char=20
*>(svrPort.GetString()));
 if(!conn)
 {  &nb=
sp;
face=3DArial size=3D2> class=3D375083115-17012008>return;   face=3DArial=20
size=3D2> }
 
 /* =
Configure=20
the BIO as a non-blocking one */
   BIO_set_nbio(conn, =

1);
   //select on read
    fd_set=20
rfds;
    struct timeval tv;
   =20
FD_ZERO(&rfds);
    int c =3D =
0;
   =20
FD_SET(BIO_get_fd(conn, &c), &rfds);
    =
//wait up to=20
five seconds
    tv.tv_sec =3D =
5;
   =20
tv.tv_usec =3D 0;

 

class=3D375083115-17012008>   =20
int retval =3D select(BIO_get_fd(conn, &c)+1, &rfds, NULL, NULL, =

&tv);
    if(retval =3D=3D =
-1)
   =20
{
        =
return;

class=3D375083115-17012008>   =20
}
    BIO_do_connect(conn);
IV>


------_=_NextPart_001_01C85922.09D76353--
__________________________________________________ ____________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majordomo@openssl.org