<p>The main <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> class. Check out <aclass="el"href="_r_e_a_d_m_e_8md.html">README.md</a> for more info.
<trclass="memdesc:ae9a7509bc8a18f67e286547c19deb3c0"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Initialize <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> with all of the prerequisites needed. <ahref="#ae9a7509bc8a18f67e286547c19deb3c0">More...</a><br/></td></tr>
<trclass="memdesc:ae6540b9a02f1392bf2ac48421189f70e"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Connect over SSL to a host specified by an IP address. <ahref="#ae6540b9a02f1392bf2ac48421189f70e">More...</a><br/></td></tr>
<trclass="memdesc:a5814c11e96848c2bcea78210f099aad5"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Connect over SSL to a host specified by a hostname. <ahref="#a5814c11e96848c2bcea78210f099aad5">More...</a><br/></td></tr>
<trclass="memdesc:a3a48b190985cdea2eba79ef0bdc80461"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Write some bytes to the SSL connection. <ahref="#a3a48b190985cdea2eba79ef0bdc80461">More...</a><br/></td></tr>
<trclass="memdesc:a40ec85568d0aec376219125b604dbc29"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the number of bytes available to read from the data that has been received and decrypted. <ahref="#a40ec85568d0aec376219125b604dbc29">More...</a><br/></td></tr>
<trclass="memdesc:ac70b900ff798f9fd33f6367fcc9fad77"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Read a single byte, or -1 if none is available. <ahref="#ac70b900ff798f9fd33f6367fcc9fad77">More...</a><br/></td></tr>
<trclass="memdesc:ae31dd88a1af8ec3794fb48f26a3dd4bf"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Read size bytes from the SSL client buffer, copying them into *buf, and return the number of bytes read. <ahref="#ae31dd88a1af8ec3794fb48f26a3dd4bf">More...</a><br/></td></tr>
<trclass="memdesc:a227b1cbbe91bcb21153c09f97d0dd484"><tdclass="mdescLeft"> </td><tdclass="mdescRight">View the first byte of the buffer, without removing it from the <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> Buffer. <ahref="#a227b1cbbe91bcb21153c09f97d0dd484">More...</a><br/></td></tr>
<trclass="memdesc:a51eb668f6a328a6a66298c6bc1361d41"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Force writing the buffered bytes from <aclass="el"href="class_s_s_l_client.html#a0699ff4b966162cba2ef59ff4a287270">SSLClient::write</a> to the network. <ahref="#a51eb668f6a328a6a66298c6bc1361d41">More...</a><br/></td></tr>
<trclass="memdesc:a158d87df3fe118b7565a19b72f310322"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Close the connection. <ahref="#a158d87df3fe118b7565a19b72f310322">More...</a><br/></td></tr>
<trclass="memdesc:a7318aadc0ec9775bffaaac0b1f00aaf8"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Check if the device is connected. <ahref="#a7318aadc0ec9775bffaaac0b1f00aaf8">More...</a><br/></td></tr>
<trclass="memdesc:ae3f27a36ff9c0cd1e2bea5e1708b6e4f"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Gets a session reference corresponding to a host and IP, or a reference to a empty session if none exist. <ahref="#ae3f27a36ff9c0cd1e2bea5e1708b6e4f">More...</a><br/></td></tr>
<trclass="memdesc:a0000d7f1e8656cf4a506a98133391fe0"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Clear the session corresponding to a host and IP. <ahref="#a0000d7f1e8656cf4a506a98133391fe0">More...</a><br/></td></tr>
<trclass="memdesc:a36bb344866e4cbcba3bbfcf4d33e5187"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Get the maximum number of SSL sessions that can be stored at once. <ahref="#a36bb344866e4cbcba3bbfcf4d33e5187">More...</a><br/></td></tr>
<trclass="memdesc:a319a722dae252efdd85fdbaf5c7fbf17"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Equivalent to <aclass="el"href="class_s_s_l_client.html#a7318aadc0ec9775bffaaac0b1f00aaf8"title="Check if the device is connected.">SSLClient::connected()</a>> 0. <ahref="#a319a722dae252efdd85fdbaf5c7fbf17">More...</a><br/></td></tr>
<trclass="memitem:a26f9418e33d4ca459f78de98d3af43bb"><tdclass="memItemLeft"align="right"valign="top">virtual bool </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="class_s_s_l_client.html#a26f9418e33d4ca459f78de98d3af43bb">operator==</a> (const C &rhs)</td></tr>
<trclass="memdesc:a26f9418e33d4ca459f78de98d3af43bb"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns whether or not two <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> objects have the same underlying client object. <ahref="#a26f9418e33d4ca459f78de98d3af43bb">More...</a><br/></td></tr>
<trclass="memitem:a518f4ed733814f2f4a8c7f838555eb35"><tdclass="memItemLeft"align="right"valign="top">virtual bool </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="class_s_s_l_client.html#a518f4ed733814f2f4a8c7f838555eb35">operator!=</a> (const C &rhs)</td></tr>
<trclass="memdesc:a518f4ed733814f2f4a8c7f838555eb35"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns whether or not two <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> objects do not have the same underlying client object. <ahref="#a518f4ed733814f2f4a8c7f838555eb35">More...</a><br/></td></tr>
<trclass="memdesc:ac725067566ee411680c88575c148300b"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns the local port, C::localPort exists. Else return 0. <ahref="#ac725067566ee411680c88575c148300b">More...</a><br/></td></tr>
<trclass="memdesc:afd0d4d2c98433d60897d8828d8047d41"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns a reference to the client object stored in this class. Take care not to break it. <ahref="#afd0d4d2c98433d60897d8828d8047d41">More...</a><br/></td></tr>
<trclass="inherit_header pub_methods_class_s_s_l_client_impl"><tdcolspan="2"onclick="javascript:toggleInherit('pub_methods_class_s_s_l_client_impl')"><imgsrc="closed.png"alt="-"/> Public Member Functions inherited from <aclass="el"href="class_s_s_l_client_impl.html">SSLClientImpl</a></td></tr>
<trclass="memdesc:ab3ebfbca41a56bfa11e34aac2c2e0106"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns an instance of m_client that is polymorphic and can be used by <aclass="el"href="class_s_s_l_client_impl.html"title="Implementation code to be inherited by SSLClient.">SSLClientImpl</a>. <ahref="#ab3ebfbca41a56bfa11e34aac2c2e0106">More...</a><br/></td></tr>
<trclass="memdesc:aaa52b481eb1d36a0ae1d208daa2fec51"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Returns an instance of the session array that is on the stack. <ahref="#aaa52b481eb1d36a0ae1d208daa2fec51">More...</a><br/></td></tr>
<trclass="inherit_header pro_methods_class_s_s_l_client_impl"><tdcolspan="2"onclick="javascript:toggleInherit('pro_methods_class_s_s_l_client_impl')"><imgsrc="closed.png"alt="-"/> Protected Member Functions inherited from <aclass="el"href="class_s_s_l_client_impl.html">SSLClientImpl</a></td></tr>
<trclass="memdesc:a9ee82ad492f2297bd7cd0835c0d4556f inherit pro_methods_class_s_s_l_client_impl"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Prints a debugging prefix to all logs, so we can attatch them to useful information. <ahref="class_s_s_l_client_impl.html#a9ee82ad492f2297bd7cd0835c0d4556f">More...</a><br/></td></tr>
<trclass="memitem:a6e701597178b81f10d0db671b81ab075 inherit pro_methods_class_s_s_l_client_impl"><tdclass="memItemLeft"align="right"valign="top">void </td><tdclass="memItemRight"valign="bottom"><aclass="el"href="class_s_s_l_client_impl.html#a6e701597178b81f10d0db671b81ab075">m_print_ssl_error</a> (const int ssl_error, const <aclass="el"href="_s_s_l_client_impl_8h.html#ab658e6d84759440dbf3c890446075395">DebugLevel</a> level) const</td></tr>
<trclass="memdesc:a6e701597178b81f10d0db671b81ab075 inherit pro_methods_class_s_s_l_client_impl"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Prints the string associated with a write error. <ahref="class_s_s_l_client_impl.html#a6e701597178b81f10d0db671b81ab075">More...</a><br/></td></tr>
<trclass="memdesc:a2cf492a714cf787e54a17bb47cda43ed inherit pro_methods_class_s_s_l_client_impl"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Print the text string associated with a BearSSL error code. <ahref="class_s_s_l_client_impl.html#a2cf492a714cf787e54a17bb47cda43ed">More...</a><br/></td></tr>
<trclass="memitem:a45a1967029784a2f0f3edc7f75a00117 inherit pro_methods_class_s_s_l_client_impl"><tdclass="memTemplParams"colspan="2">template<typename T ></td></tr>
<trclass="memdesc:a45a1967029784a2f0f3edc7f75a00117 inherit pro_methods_class_s_s_l_client_impl"><tdclass="mdescLeft"> </td><tdclass="mdescRight">debugging print function, only prints if m_debug is true <ahref="class_s_s_l_client_impl.html#a45a1967029784a2f0f3edc7f75a00117">More...</a><br/></td></tr>
<trclass="memitem:a3b4cb1e9e510955078b83c9f84c0e18c inherit pro_methods_class_s_s_l_client_impl"><tdclass="memTemplParams"colspan="2">template<typename T ></td></tr>
<trclass="memitem:a3b4cb1e9e510955078b83c9f84c0e18c inherit pro_methods_class_s_s_l_client_impl"><tdclass="memTemplItemLeft"align="right"valign="top">void </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="class_s_s_l_client_impl.html#a3b4cb1e9e510955078b83c9f84c0e18c">m_info</a> (const T str, const char *func_name) const</td></tr>
<trclass="memdesc:a3b4cb1e9e510955078b83c9f84c0e18c inherit pro_methods_class_s_s_l_client_impl"><tdclass="mdescLeft"> </td><tdclass="mdescRight">Prints a info message to serial, if info messages are enabled. <ahref="class_s_s_l_client_impl.html#a3b4cb1e9e510955078b83c9f84c0e18c">More...</a><br/></td></tr>
<trclass="memitem:a2bfb55bcde46d8d77a46bfe0f577bf3f inherit pro_methods_class_s_s_l_client_impl"><tdclass="memTemplParams"colspan="2">template<typename T ></td></tr>
<trclass="memitem:a2bfb55bcde46d8d77a46bfe0f577bf3f inherit pro_methods_class_s_s_l_client_impl"><tdclass="memTemplItemLeft"align="right"valign="top">void </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="class_s_s_l_client_impl.html#a2bfb55bcde46d8d77a46bfe0f577bf3f">m_warn</a> (const T str, const char *func_name) const</td></tr>
<trclass="memitem:ada595ed8f11673a9180ef0b762949c83 inherit pro_methods_class_s_s_l_client_impl"><tdclass="memTemplParams"colspan="2">template<typename T ></td></tr>
<trclass="memitem:ada595ed8f11673a9180ef0b762949c83 inherit pro_methods_class_s_s_l_client_impl"><tdclass="memTemplItemLeft"align="right"valign="top">void </td><tdclass="memTemplItemRight"valign="bottom"><aclass="el"href="class_s_s_l_client_impl.html#ada595ed8f11673a9180ef0b762949c83">m_error</a> (const T str, const char *func_name) const</td></tr>
<p>The main <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> class. Check out <aclass="el"href="_r_e_a_d_m_e_8md.html">README.md</a> for more info. </p>
<p>Initialize <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> with all of the prerequisites needed. </p>
<dlclass="section pre"><dt>Precondition</dt><dd>You will need to generate an array of trust_anchors (root certificates) based off of the domains you want to make SSL connections to. Check out the <aclass="el"href="_trust_anchors_8md.html">TrustAnchors.md</a> file for more info. </dd>
<tr><tdclass="paramname">client</td><td>The base network device to create an SSL socket on. This object will be copied and the copy will be stored in <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a>. </td></tr>
<tr><tdclass="paramname">trust_anchors</td><td>Trust anchors used in the verification of the SSL server certificate. Check out <aclass="el"href="_trust_anchors_8md.html">TrustAnchors.md</a> for more info. </td></tr>
<tr><tdclass="paramname">trust_anchors_num</td><td>The number of objects in the trust_anchors array. </td></tr>
<tr><tdclass="paramname">analog_pin</td><td>An analog pin to pull random bytes from, used in seeding the RNG. </td></tr>
<tr><tdclass="paramname">debug</td><td>The level of debug logging (use the <aclass="el"href="_s_s_l_client_impl_8h.html#ab658e6d84759440dbf3c890446075395"title="Level of verbosity used in logging for SSLClient.">DebugLevel</a> enum). </td></tr>
</table>
</dd>
</dl>
</div>
</div>
<h2class="groupheader">Member Function Documentation</h2>
<p>Returns the number of bytes available to read from the data that has been received and decrypted. </p>
<p>This function updates the state of the SSL engine (including writing any data, see <aclass="el"href="class_s_s_l_client.html#a0699ff4b966162cba2ef59ff4a287270">SSLClient::write</a>) and as a result should be called periodically when expecting data. Additionally, since if there are no bytes and if <aclass="el"href="class_s_s_l_client.html#a7318aadc0ec9775bffaaac0b1f00aaf8"title="Check if the device is connected.">SSLClient::connected</a> is false this function returns zero (this same behavior is found in EthernetClient), it is prudent to ensure in your own code that the preconditions are met before checking this function to prevent an ambiguous result.</p>
<dlclass="section pre"><dt>Precondition</dt><dd><aclass="el"href="class_s_s_l_client.html#a7318aadc0ec9775bffaaac0b1f00aaf8"title="Check if the device is connected.">SSLClient::connected</a> must be true.</dd></dl>
<dlclass="section return"><dt>Returns</dt><dd>The number of bytes available (can be zero), or zero if any of the pre conditions aren't satisfied. </dd></dl>
<p>SSLClient::connect(host, port) should be preferred over this function, as verifying the domain name is a step in ensuring the certificate is legitimate, which is important to the security of the device. Additionally, SSL sessions cannot be resumed when using this function, which can drastically increase initial connect time.</p>
<p>This function initializes the socket by calling m_client::connect(IPAddress, uint16_t) with the parameters supplied, then once the socket is open, uses BearSSL to to complete a SSL handshake. Due to the design of the SSL standard, this function will probably take an extended period (1-4sec) to negotiate the handshake and finish the connection. This function runs until the SSL handshake succeeds or fails.</p>
<p>SSL requires the client to generate some random bits (to be later combined with some random bits from the server), so <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> uses the least significant bits from the analog pin supplied in the constructor. The random bits are generated from 16 consecutive analogReads, and given to BearSSL before the handshake starts.</p>
<p>The implementation for this function can be found in <aclass="el"href="class_s_s_l_client_impl.html#aa5c14ecf301c268306946c85825e565b">SSLClientImpl::connect_impl(IPAddress, uint16_t)</a>.</p>
<dlclass="section pre"><dt>Precondition</dt><dd>The underlying client object (passed in through the constructor) is in a non- error state, and must be able to access the IP. </dd>
<aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> can only have one connection at a time, so the client object must not already be connected. </dd>
There must be sufficient memory available on the device to verify the certificate (if the free memory drops below 8000 bytes during certain points in the connection, <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> will fail). </dd>
There must be a trust anchor given to the constructor that corresponds to the certificate provided by the IP address being connected to. For more information check out <aclass="el"href="_trust_anchors_8md.html">TrustAnchors.md</a> .</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">ip</td><td>The IP address to connect to </td></tr>
<tr><tdclass="paramname">port</td><td>the port to connect to </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>1 if success, 0 if failure </dd></dl>
<p>This function initializes the socket by calling m_client::connect(const char*, uint16_t) with the parameters supplied, then once the socket is open, uses BearSSL to complete a SSL handshake. This function runs until the SSL handshake succeeds or fails.</p>
<p>SSL requires the client to generate some random bits (to be later combined with some random bits from the server), so <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> uses the least significant bits from the analog pin supplied in the constructor. The random bits are generated from 16 consecutive analogReads, and given to BearSSL before the handshake starts.</p>
<p>This function will usually take around 4-10 seconds. If possible, this function also attempts to resume the SSL session if one is present matching the hostname string, which will reduce connection time to 100-500ms. To read more about this functionality, check out Session Caching in the README.</p>
<p>The implementation for this function can be found in <aclass="el"href="class_s_s_l_client_impl.html#ae6c947ad92979ab99364428004abbeba">SSLClientImpl::connect_impl(const char*, uint16_t)</a></p>
<dlclass="section pre"><dt>Precondition</dt><dd>The underlying client object (passed in through the constructor) is in a non- error state, and must be able to access the IP. </dd>
<aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> can only have one connection at a time, so the client object must not already be connected. </dd>
There must be sufficient memory available on the device to verify the certificate (if the free memory drops below 8000 bytes during certain points in the connection, <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> will fail). </dd>
There must be a trust anchor given to the constructor that corresponds to the certificate provided by the IP address being connected to. For more information check out <aclass="el"href="_trust_anchors_8md.html">TrustAnchors.md</a> .</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">host</td><td>The hostname as a null-terminated c-string ("www.google.com") </td></tr>
<tr><tdclass="paramname">port</td><td>The port to connect to on the host (443 for HTTPS) </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>1 of success, 0 if failure </dd></dl>
<p>Use this function to determine if <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> is still connected and a SSL connection is active. It should be noted that <aclass="el"href="class_s_s_l_client.html#a40ec85568d0aec376219125b604dbc29"title="Returns the number of bytes available to read from the data that has been received and decrypted.">SSLClient::available</a> should be preferred over this function for rapid polling–both functions send and receive data with the SSLClient::m_client device, however <aclass="el"href="class_s_s_l_client.html#a40ec85568d0aec376219125b604dbc29"title="Returns the number of bytes available to read from the data that has been received and decrypted.">SSLClient::available</a> has some delays built in to protect SSLClient::m_client from being polled too frequently.</p>
<p>The implementation for this function can be found in <aclass="el"href="class_s_s_l_client_impl.html#a957984fa392550a7df86f758e9b14bfb">SSLClientImpl::connected_impl</a>.</p>
<dlclass="section return"><dt>Returns</dt><dd>1 if connected, 0 if not </dd></dl>
<p>Force writing the buffered bytes from <aclass="el"href="class_s_s_l_client.html#a0699ff4b966162cba2ef59ff4a287270">SSLClient::write</a> to the network. </p>
<p>This function is blocking until all bytes from the buffer are written. For an explanation of how writing with <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> works, please see <aclass="el"href="class_s_s_l_client.html#a0699ff4b966162cba2ef59ff4a287270">SSLClient::write</a>. The implementation for this function can be found in SSLClientImpl::flush. </p>
<p>Returns an instance of m_client that is polymorphic and can be used by <aclass="el"href="class_s_s_l_client_impl.html"title="Implementation code to be inherited by SSLClient.">SSLClientImpl</a>. </p>
<p>If no session corresponding to the host and IP exist, then this function will cycle through sessions in a rotating order. This allows the session cache to continually store sessions, however it will also result in old sessions being cleared and returned. In general, it is a good idea to use a SessionCache size equal to the number of domains you plan on connecting to.</p>
<p>The implementation for this function can be found at <aclass="el"href="class_s_s_l_client_impl.html#ab4e38d4319ec504395d67d2ab21a639e">SSLClientImpl::get_session_impl</a>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">host</td><td>A hostname c string, or NULL if one is not available </td></tr>
<tr><tdclass="paramname">addr</td><td>An IP address </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>A reference to an <aclass="el"href="class_s_s_l_session.html"title="This class stores values which allow SSLClient to save and resume SSL sessions.">SSLSession</a> object </dd></dl>
<p>Equivalent to <aclass="el"href="class_s_s_l_client.html#a7318aadc0ec9775bffaaac0b1f00aaf8"title="Check if the device is connected.">SSLClient::connected()</a>> 0. </p>
<p>Returns whether or not two <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> objects do not have the same underlying client object. </p>
<p>Returns whether or not two <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> objects have the same underlying client object. </p>
<p>View the first byte of the buffer, without removing it from the <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> Buffer. </p>
<p>The implementation for this function can be found in SSLClientImpl::peek </p><dlclass="section pre"><dt>Precondition</dt><dd><aclass="el"href="class_s_s_l_client.html#a40ec85568d0aec376219125b604dbc29"title="Returns the number of bytes available to read from the data that has been received and decrypted.">SSLClient::available</a> must be >0 </dd></dl>
<dlclass="section return"><dt>Returns</dt><dd>The first byte received, or -1 if the preconditions are not satisfied (warning: do not use if your data may be -1, as the return value is ambiguous) </dd></dl>
<dlclass="section see"><dt>See also</dt><dd><aclass="el"href="class_s_s_l_client.html#ae31dd88a1af8ec3794fb48f26a3dd4bf"title="Read size bytes from the SSL client buffer, copying them into *buf, and return the number of bytes re...">SSLClient::read(uint8_t*, size_t)</a></dd></dl>
<p>Read size bytes from the SSL client buffer, copying them into *buf, and return the number of bytes read. </p>
<p>This function checks if bytes are ready to be read by calling <aclass="el"href="class_s_s_l_client.html#a40ec85568d0aec376219125b604dbc29"title="Returns the number of bytes available to read from the data that has been received and decrypted.">SSLClient::available</a>, and if so copies size number of bytes from the IO buffer into the buf pointer. Data read using this function will not include any SSL or socket commands, as the Client and BearSSL will capture those and process them separately.</p>
<p>If you find that you are having a lot of timeout errors, <aclass="el"href="class_s_s_l_client.html"title="The main SSLClient class. Check out README.md for more info.">SSLClient</a> may be experiencing a buffer overflow. Checkout <aclass="el"href="_r_e_a_d_m_e_8md.html">README.md</a> for more information.</p>
<p>The implementation for this function can be found in <aclass="el"href="class_s_s_l_client_impl.html#a231b7b1bb2182cda1ed6e9d5ebf66afe">SSLClientImpl::read_impl(uint8_t*, size_t)</a></p>
<dlclass="section pre"><dt>Precondition</dt><dd><aclass="el"href="class_s_s_l_client.html#a40ec85568d0aec376219125b604dbc29"title="Returns the number of bytes available to read from the data that has been received and decrypted.">SSLClient::available</a> must be >0</dd></dl>
<p>Clear the session corresponding to a host and IP. </p>
<p>The implementation for this function can be found at <aclass="el"href="class_s_s_l_client_impl.html#a6baed094969874fb9d2bea3a00ecbee1">SSLClientImpl::remove_session_impl</a>.</p>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">host</td><td>A hostname c string, or NULL if one is not available </td></tr>
<tr><tdclass="paramname">addr</td><td>An IP address </td></tr>
<p>If the SSL session is still active, all incoming data is discarded and BearSSL will attempt to close the session gracefully (will write to the network), and then call m_client::stop. If the session is not active or an error was encountered previously, this function will simply call m_client::stop. The implementation for this function can be found in SSLClientImpl::peek. </p>
<p>Assuming all preconditions are met, this function writes data to the BearSSL IO buffer, BUT does not initially send the data. Instead, you must call <aclass="el"href="class_s_s_l_client.html#a40ec85568d0aec376219125b604dbc29"title="Returns the number of bytes available to read from the data that has been received and decrypted.">SSLClient::available</a> or <aclass="el"href="class_s_s_l_client.html#a51eb668f6a328a6a66298c6bc1361d41"title="Force writing the buffered bytes from SSLClient::write to the network.">SSLClient::flush</a>, which will detect that the buffer is ready for writing, and will write the data to the network. Alternatively, if this function is requested to write a larger amount of data than SSLClientImpl::m_iobuf can handle, data will be written to the network in pages the size of SSLClientImpl::m_iobuf until all the data in buf is sent–attempting to keep all writes to the network grouped together. For information on why this is the case check out <aclass="el"href="_r_e_a_d_m_e_8md.html">README.md</a> .</p>
<p>The implementation for this function can be found in <aclass="el"href="class_s_s_l_client_impl.html#a807656f814f24cf6cd711e429b716c4d">SSLClientImpl::write_impl(const uint8_t*, size_t)</a></p>
<dlclass="section pre"><dt>Precondition</dt><dd>The socket and SSL layer must be connected, meaning <aclass="el"href="class_s_s_l_client.html#a7318aadc0ec9775bffaaac0b1f00aaf8"title="Check if the device is connected.">SSLClient::connected</a> must be true. </dd>
BearSSL must not be waiting for the recipt of user data (if it is, there is probably an error with how the protocol in implemented in your code).</dd></dl>
<dlclass="params"><dt>Parameters</dt><dd>
<tableclass="params">
<tr><tdclass="paramname">buf</td><td>the pointer to a buffer of bytes to copy </td></tr>
<tr><tdclass="paramname">size</td><td>the number of bytes to copy from the buffer </td></tr>
</table>
</dd>
</dl>
<dlclass="section return"><dt>Returns</dt><dd>The number of bytes copied to the buffer (size), or zero if the BearSSL engine fails to become ready for writing data. </dd></dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>