4 /* A minimal program to connect to a port using the sock4a protocol.
6 * cc -I../../include conn.c -L../.. -lcrypto
10 #include <openssl/err.h>
11 #include <openssl/bio.h>
12 /* #include "proxy.h" */
27 host="localhost:4433";
31 /* Lets get nice error messages */
32 ERR_load_crypto_strings();
34 /* First, configure proxy settings */
36 PROXY_add_server(pxy,PROXY_PROTOCOL_SOCKS,"gromit:1080");
38 bio=BIO_new(BIO_s_socks4a_connect());
40 BIO_set_conn_hostname(bio,host);
41 BIO_set_proxies(bio,pxy);
42 BIO_set_socks_userid(bio,"eay");
45 p="GET / HTTP/1.0\r\n\r\n";
51 i=BIO_write(bio,&(p[off]),len);
54 if (BIO_should_retry(bio))
56 fprintf(stderr,"write DELAY\n");
72 i=BIO_read(bio,buf,sizeof(buf));
76 if (BIO_should_retry(bio))
78 fprintf(stderr,"read DELAY\n");
84 fwrite(buf,1,i,stdout);
92 if (ERR_peek_error() == 0) /* system call error */
94 fprintf(stderr,"errno=%d ",errno);
98 ERR_print_errors_fp(stderr);
101 if (pxy != NULL) PROXY_free(pxy);