Skip to content

Instantly share code, notes, and snippets.

@Marenz
Created September 25, 2015 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marenz/adc7570c18dbbc858678 to your computer and use it in GitHub Desktop.
Save Marenz/adc7570c18dbbc858678 to your computer and use it in GitHub Desktop.
//before
in_buffer.length = packet_length;
conn.read(in_buffer);
// now
while ( in_buffer.length < packet_size && conn.connected )
{
if ( conn.waitForData(1.seconds) )
{
auto added_len = in_buffer.length + conn.leastSize > packet_size ?
packet_size : conn.leastSize;
in_buffer.length += added_len;
conn.read(in_buffer[$-added_len .. $]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment