=== Problem 2: Packets Pile Up ===
 
=== Problem 2: Packets Pile Up ===
   −
When OpenSSL is operating, particularly when starting up a new TLS or DTLS session, it needs to read and write multiple packets in order to complete negotiations.  Internally OpenSSL will attempt to read as much as it can from the BIO it was given in order to process as much as possible before returning control to the application (possibly with data).
+
When OpenSSL is operating, particularly when starting up a new TLS or DTLS session, it needs to read and write multiple packets in order to complete negotiations.  Internally OpenSSL will attempt to read as much as it can from the BIO it was given in order to process as much as possible before returning control to the application (with or without data for it).
   −
In the case of TLS over TCP, this is perfectly safe since the the BIO is attached to a socket where all the data coming through the socket should be destined for that one TLS connection (and if it's not, it's safe to throw away).
+
In the case of TLS over TCP, this is perfectly safe since the the BIO is attached to a socket where all the data coming through the socket should be destined for that one TLS connection.
   −
However!  This concept of reading as much as you want fails completely when using UDP.  The first packet may certainly be destined for the current ''SSL *'' context (especially if the application handed it carefully to OpenSSL as described above).  But there is no guarantee that the next packet will be from the same client or the same TLS session.
+
However!  This concept of reading as much as you want fails completely when using UDP.  The first packet may certainly be destined for the current ''SSL *'' session (especially if the application handed it carefully to OpenSSL as described above).  But there is no guarantee that the next packet will be from the same client or the same (D)TLS session.
   Exception encountered, of type "Error"