canl_err.lo: canl_err.c ${HEAD_CANL}
${COMPILE} -c ${top_srcdir}/src/canl_err.c ${CFLAGS_LIB} -o $@
-canl_ssl.lo: canl_err.c ${HEAD_CANL}
+canl_ssl.lo: canl_ssl.c ${HEAD_CANL}
${COMPILE} -c ${top_srcdir}/src/canl_ssl.c ${CFLAGS_LIB} -o $@
client: ${OBJ_CLI}
glb_ctx *glb_cc = (glb_ctx*) cc;
int b_written = 0;
int err = 0;
+ errno = 0;
if (!cc) {
return -1;
goto end;
}
- //TODO testing: read something without using openssl
- b_written = send(io_cc->sock, "Hello, world!", 13, 0);
+ //read something using openssl
+ b_written = ssl_write(glb_cc, io_cc, buffer, size, timeout);
if (b_written == -1) {
err = errno; //TODO check again
goto end;
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
+#include <string.h>
#include "canl.h"
#define BUF_LEN 1000
int err = 0;
char *err_msg = NULL;
char buf[BUF_LEN];
+ int buf_len = 0;
char *p_server = NULL;
char *def_server = "www.linuxfoundation.org";
int opt, port = 80;
printf("connection cannot be established\n");
goto end;
}
+ else {
+ printf("connection established\n");
+ }
- err = canl_io_write (my_ctx, my_io_h, NULL, 0, NULL);
- if (err) {
- //set_error ("cannot write");
+ strcpy(buf, "This is the testing message to send");
+ buf_len = strlen(buf) + 1;
+
+ printf("Trying to send sth to the server\n");
+ err = canl_io_write (my_ctx, my_io_h, buf, buf_len, NULL);
+ if (err <= 0) {
+ printf("can't write using ssl\n");
+ goto end;
+ }
+ else {
+ buf[err] = '\0';
+ printf("message \"%s\" sent successfully\n", buf);
}
err = canl_io_read (my_ctx, my_io_h, buf, sizeof(buf)-1, NULL);