yeah you would think that but it doesnt for some strange reason.

Girish Venkatachalam <[EMAIL PROTECTED]> wrote:
Looks like I have not understood your problem.

Why do you have to do an SSL_read() to figure out if
it has closed? SSL_write() will fail it the other side
closes...

--- michael Dorrian <[EMAIL PROTECTED]>wrote:

> Here is the relevant code. The problem is in this
> do_client_loop. I need to read from the server to
> check if it has closed but when i do this i cannot
> write to the server again for some reason. How can i
> rectify this......thanks in advance
> int do_client_loop(SSL *ssl)
> {
> int err, nwritten;
> char buf[80];
> for (;;)
> {
> if (!fgets(buf, sizeof(buf), stdin))
> break;
>
> for (nwritten = 0; nwritten < sizeof(buf);
> nwritten += err)
> {
> err = SSL_write(ssl, buf + nwritten,
> sizeof(buf) - nwritten);
> if (err <= 0)
> return 0;
>
>
> }
> err = SSL_read(ssl, buf + nwritten, sizeof(buf)
> - nwritten);
> if (err <= 0)
> return 0;
>
> }
> return 1;
> }
>
> int main(int argc, char *argv[])
> {
> BIO *conn;
> SSL *ssl;
> SSL_CTX *ctx;
> long err;
> init_OpenSSL( );
> seed_prng( );
> clientfile = argv[1];
> ctx = setup_client_ctx( );
>
> conn = BIO_new_connect(SERVER ":" PORT);
> if (!conn)
> int_error("Error creating connection BIO");
>
> if (BIO_do_connect(conn) <= 0)
> int_error("Error connecting to remote
> machine");
>
> ssl = SSL_new(ctx);
> SSL_set_bio(ssl, conn, conn);
> if (SSL_connect(ssl) <= 0)
> int_error("Error connecting SSL object");
> if ((err = post_connection_check(ssl, SERVER))
> != X509_V_OK)
> {
> fprintf(stderr, "-Error: peer certificate:
> %s\n",
>
> X509_verify_cert_error_string(err));
> int_error("Error checking SSL object after
> connection");
> }
> fprintf(stderr, "SSL Connection opened\n");
> if (do_client_loop(ssl))
> SSL_shutdown(ssl);
> else
> SSL_clear(ssl);
> fprintf(stderr, "SSL Connection closed\n");
>
> SSL_free(ssl);
> SSL_CTX_free(ctx);
> return 0;
> }
>
> ---------------------------------
> Blab-away for as little as 1E½/min. Make
PC-to-Phone
> Calls using Yahoo! Messenger with Voice.


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager [EMAIL PROTECTED]


Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

Reply via email to