On Thu, Feb 22, 2007, Milan K?pek wrote:

> Hi, In my project I try to set up TCP connection. It works fine on Unix 
> systems, but when I try it on Windows I have problem.
> For connecting I use the non blocking BIO.
> Here is part of the code I use:
> 
> BIO_set_nbio (bio,1);
> 
> int rc = -1;
> while (rc <= 0){
>   rc = BIO_do_connect(bio);
>   if (rc<=0){
>     if (!BIO_should_retry(bio)){
>       return (OT_ERROR);
>     }
>   }
> }
> 
> I set BIO to nonblocking and than I try to connect, until it connects or 
> throws an error.
> On windows system I have this problem, this code is finished even the 
> connection wasnt established.
> I try connection to another computer, that I disconnect from LAN. In unix 
> system, it throws error, but in windows, it says me that connect was 
> succesfully established :o(
> 
> Please what should I do. I need some advice how to recognize if the 
> connection is avaiable.
> I used to try select function. Guarding the filedesriptor of bio, and 
> watching if this socket is writeable. but it never happen.
> 

While that technique will work under Unix it wont on Win32 due to some
differences in the way connect() operates in non blocking mode. I suppose we
should really modify the connect BIO under Win32 to allow that to work.

A slightly different technique should work on both. After the call to
BIO_do_connect() retrieve the fd and if a retry is requested wait for a write
condition: this indicates that the connection has completed.

After that perform I/O on the BIO in the normal way.

There is an example of this in the ocsp application in OpenSSL 0.9.9-dev.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to