request_end), &amp;written)) {
    printf(&quot;Failed to write end of HTTP request\n&quot;);
    goto end;
}</code></pre>

<p>The <a href="../man3/SSL_write_ex.html">SSL_write_ex(3)</a> function returns 0 if it fails and 1 if it is successful. If it is successful then we can proceed to waiting for a response from the server.</p>

<pre><code>size_t readbytes;
char buf[160];

/*
 * Get up to sizeof(buf) bytes of the response. We keep reading until the
 * server closes the connection.
 */
while (SSL_read_ex(s