mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-03 14:24:15 +01:00
Change the return type of write() from void to size_t on WiFiServer class
This commit is contained in:
parent
20bea5fcc0
commit
af0dd1926a
@ -27,6 +27,8 @@ public:
|
|||||||
|
|
||||||
friend class WiFiServer;
|
friend class WiFiServer;
|
||||||
|
|
||||||
|
using Print::write;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static uint16_t _srcport;
|
static uint16_t _srcport;
|
||||||
uint8_t _sock; //not used
|
uint8_t _sock; //not used
|
||||||
|
@ -46,13 +46,15 @@ WiFiClient WiFiServer::available(byte* status)
|
|||||||
return WiFiClient(255);
|
return WiFiClient(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiFiServer::write(uint8_t b)
|
size_t WiFiServer::write(uint8_t b)
|
||||||
{
|
{
|
||||||
write(&b, 1);
|
return write(&b, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiFiServer::write(const uint8_t *buffer, size_t size)
|
size_t WiFiServer::write(const uint8_t *buffer, size_t size)
|
||||||
{
|
{
|
||||||
|
size_t n = 0;
|
||||||
|
|
||||||
for (int sock = 0; sock < MAX_SOCK_NUM; sock++)
|
for (int sock = 0; sock < MAX_SOCK_NUM; sock++)
|
||||||
{
|
{
|
||||||
if (WiFiClass::_server_port[sock] != 0)
|
if (WiFiClass::_server_port[sock] != 0)
|
||||||
@ -62,8 +64,9 @@ void WiFiServer::write(const uint8_t *buffer, size_t size)
|
|||||||
if (WiFiClass::_server_port[sock] == _port &&
|
if (WiFiClass::_server_port[sock] == _port &&
|
||||||
client.status() == ESTABLISHED)
|
client.status() == ESTABLISHED)
|
||||||
{
|
{
|
||||||
client.write(buffer, size);
|
n+=client.write(buffer, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,10 @@ public:
|
|||||||
WiFiServer(uint16_t);
|
WiFiServer(uint16_t);
|
||||||
WiFiClient available(uint8_t* status = NULL);
|
WiFiClient available(uint8_t* status = NULL);
|
||||||
void begin();
|
void begin();
|
||||||
virtual void write(uint8_t);
|
virtual size_t write(uint8_t);
|
||||||
virtual void write(const uint8_t *buf, size_t size);
|
virtual size_t write(const uint8_t *buf, size_t size);
|
||||||
|
|
||||||
|
using Print::write;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user