1
0
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:
mlafauci 2011-09-14 00:13:31 +02:00
parent 20bea5fcc0
commit af0dd1926a
3 changed files with 13 additions and 6 deletions

View File

@ -27,6 +27,8 @@ public:
friend class WiFiServer;
using Print::write;
private:
static uint16_t _srcport;
uint8_t _sock; //not used

View File

@ -46,13 +46,15 @@ WiFiClient WiFiServer::available(byte* status)
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++)
{
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 &&
client.status() == ESTABLISHED)
{
client.write(buffer, size);
n+=client.write(buffer, size);
}
}
}
return n;
}

View File

@ -17,8 +17,10 @@ public:
WiFiServer(uint16_t);
WiFiClient available(uint8_t* status = NULL);
void begin();
virtual void write(uint8_t);
virtual void write(const uint8_t *buf, size_t size);
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buf, size_t size);
using Print::write;
};
#endif