인디노트

BIO client example 본문

인증기술/OpenSSL

BIO client example

인디개발자 2018. 11. 15. 14:00
 BIO *cbio, *out;
 int len;
 char tmpbuf[1024];

 cbio = BIO_new_connect("localhost:http");
 out = BIO_new_fp(stdout, BIO_NOCLOSE);
 if (BIO_do_connect(cbio) <= 0) {
     fprintf(stderr, "Error connecting to server\n");
     ERR_print_errors_fp(stderr);
     exit(1);
 }
 BIO_puts(cbio, "GET / HTTP/1.0\n\n");
 for (;;) {
     len = BIO_read(cbio, tmpbuf, 1024);
     if (len <= 0)
         break;
     BIO_write(out, tmpbuf, len);
 }
 BIO_free(cbio);
 BIO_free(out);


반응형

'인증기술 > OpenSSL' 카테고리의 다른 글

An Introduction to OpenSSL Programming, Part I of II  (0) 2019.01.21
non blocking SSL  (0) 2018.11.16
ssl_client.c  (0) 2018.11.11
Openssl을 이용한 암호화 통신  (0) 2018.11.11
OpenSSL Client/Server  (0) 2018.11.11
Comments