#include #include #include #include #include #include int main(int argc, char **argv) { SSL_CTX *ctx = SSL_CTX_new(TLS_client_method()); SSL *ssl = SSL_new(ctx); struct hostent *he = gethostbyname(argv[1]); struct sockaddr_in sa; sa.sin_family = AF_INET; sa.sin_port = htons(atoi(argv[2])); memcpy(&sa.sin_addr.s_addr, he->h_addr, he->h_length); int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); connect(fd, (struct sockaddr *)&sa, sizeof(sa)); SSL_set_fd(ssl, fd); SSL_connect(ssl); SSL_write(ssl, "Hello, Server!\n", 15); char buf[1024]; int count = SSL_read(ssl, buf, sizeof(buf)); write(1, buf, count); SSL_shutdown(ssl); close(fd); SSL_free(ssl); SSL_CTX_free(ctx); return 0; }