Gabriel Soto wrote:
>
> Greetings.
> I'm a noob trying to code a simple TCP client (Windows, MinGW, OpenSSL 0.9.8g). Since it has a GUI, I have to go with non-blocking sockets.
>
> I'm supplying a nonexistent host to test a failure but this is what happens:
> A first call to connect returns naturally "no connection" and BIO_should_retry() returns true. But the second time I call connect, even immediately after the first call, it gives me an OK.
>
> Here's the basic code:
> {
> // Create BIO with some random nonexistent host.
> BIO *bio = BIO_new_connect("192.168.9.9:9999");
>
> if (bio == NULL) {
> // Failed to obtain BIO.
> return false;
> }
>
> // Set as non-blocking.
> BIO_set_nbio(bio, 1);
>
> // Attempt to connect.
> printf("BIO_do_connect: %ld\n", BIO_do_connect(bio));
> printf("BIO_should_retry: %d\n", BIO_should_retry(bio));
>
> // Try again. Not much sense in this, but let's see what happens.
> printf("BIO_do_connect: %ld\n", BIO_do_connect(bio));
> printf("BIO_should_retry: %d\n", BIO_should_retry(bio));
> }
>
> Output:
> BIO_do_connect: -1
> BIO_should_retry: 8
> BIO_do_connect: 1
> BIO_should_retry: 8
>
> Does this make sense?
> Why does BIO_do_connect() return 1 the second time?
>
> Thanks.


Can anybody just confirm that this is a strange behavior. Maybe I'm
getting things wrong.
Any example code of a client using non-blocking sockets will be
greatly appreciated too.
__________________________________________________ ____________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majordomo@openssl.org