We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 861da4c commit d717b58Copy full SHA for d717b58
libraries/WiFi/src/include/ClientContext.h
@@ -374,12 +374,22 @@ class ClientContext {
374
return 0;
375
}
376
size_t sent = 0;
377
+ uint8_t buff[128];
378
while (stream.available()) {
- char b;
379
- b = stream.read();
380
- if (write(&b, 1)) {
381
- sent ++;
+ // Stream only lets you read 1 byte at a time, so buffer in local copy
+ size_t i;
+ for (i = 0; (i < sizeof(buff)) && stream.available(); i++) {
382
+ buff[i] = stream.read();
383
+ }
384
+ if (i) {
385
+ // Send as a single packet
386
+ int len = write((const char *)buff, i);
387
+ sent += len;
388
+ if (len != (int)i) {
389
+ break; // Write error...
390
391
} else {
392
+ // Out of data...
393
break;
394
395
0 commit comments