mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
add template client write
can read streams that have "available()" and "read(buf, len)" methods thanks @igrr
This commit is contained in:
parent
74a2b75cf9
commit
5eee3da4d5
@ -56,6 +56,28 @@ public:
|
|||||||
IPAddress remoteIP();
|
IPAddress remoteIP();
|
||||||
uint16_t remotePort();
|
uint16_t remotePort();
|
||||||
|
|
||||||
|
template<typename T> size_t write(T &src){
|
||||||
|
uint8_t obuf[1460];
|
||||||
|
size_t doneLen = 0;
|
||||||
|
size_t sentLen;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
while (src.available() > 1460){
|
||||||
|
src.read(obuf, 1460);
|
||||||
|
sentLen = write(obuf, 1460);
|
||||||
|
doneLen = doneLen + sentLen;
|
||||||
|
if(sentLen != 1460){
|
||||||
|
return doneLen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t leftLen = src.available();
|
||||||
|
src.read(obuf, leftLen);
|
||||||
|
sentLen = write(obuf, leftLen);
|
||||||
|
doneLen = doneLen + sentLen;
|
||||||
|
return doneLen;
|
||||||
|
}
|
||||||
|
|
||||||
friend class WiFiServer;
|
friend class WiFiServer;
|
||||||
|
|
||||||
using Print::write;
|
using Print::write;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user