From af0dd1926af1920a0dc10e9cf20d3e1036391398 Mon Sep 17 00:00:00 2001 From: mlafauci Date: Wed, 14 Sep 2011 00:13:31 +0200 Subject: [PATCH] Change the return type of write() from void to size_t on WiFiServer class --- WiFi/WiFiClient.h | 2 ++ WiFi/WiFiServer.cpp | 11 +++++++---- WiFi/WiFiServer.h | 6 ++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/WiFi/WiFiClient.h b/WiFi/WiFiClient.h index 919532f41..5a7f0f3b8 100755 --- a/WiFi/WiFiClient.h +++ b/WiFi/WiFiClient.h @@ -27,6 +27,8 @@ public: friend class WiFiServer; + using Print::write; + private: static uint16_t _srcport; uint8_t _sock; //not used diff --git a/WiFi/WiFiServer.cpp b/WiFi/WiFiServer.cpp index 8461583aa..860759383 100755 --- a/WiFi/WiFiServer.cpp +++ b/WiFi/WiFiServer.cpp @@ -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; } diff --git a/WiFi/WiFiServer.h b/WiFi/WiFiServer.h index 2871d06da..d93b0ced1 100755 --- a/WiFi/WiFiServer.h +++ b/WiFi/WiFiServer.h @@ -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