* Lookup IP address info for the server.
*/
if (!BIO_lookup_ex(hostname, port, BIO_LOOKUP_CLIENT, 0, SOCK_STREAM, 0,
- &res)) {
- BIO_closesocket(sock);
+ &res))
return NULL;
- }
/*
* Loop through all the possible addresses for the server and find one
OpenSSL provides portable helper functions to do these tasks which also
integrate into the OpenSSL error system to log error data, e.g.
- BIO_ADDRINFO *ai = NULL;
+ int sock = -1;
+ BIO_ADDRINFO *res;
+ const BIO_ADDRINFO *ai = NULL;
/*
* Lookup IP address info for the server.
*/
if (!BIO_lookup_ex(hostname, port, BIO_LOOKUP_CLIENT, 0, SOCK_STREAM, 0,
- &res)) {
- BIO_closesocket(sock);
+ &res))
return NULL;
- }
/*
* Loop through all the possible addresses for the server and find one
sock = -1;
continue;
}
+
+ /* We have a connected socket so break out of the loop */
+ break;
}
/* Free the address information resources we allocated earlier */
client always writes data first.
size_t written;
- const char *request = "GET / HTTP/1.0\r\nHost: "HOSTNAME"\r\n\r\n";
+ const char *request =
+ "GET / HTTP/1.0\r\nConnection: close\r\nHost: "HOSTNAME"\r\n\r\n";
/* Write an HTTP GET request to the peer */
if (!SSL_write_ex(ssl, request, strlen(request), &written)) {