diff options
author | David A. Mellis <d.mellis@arduino.cc> | 2009-04-26 13:10:34 +0000 |
---|---|---|
committer | David A. Mellis <d.mellis@arduino.cc> | 2009-04-26 13:10:34 +0000 |
commit | 0681fc1f177f7c94b4e98bb0931a5efda50f32b0 (patch) | |
tree | 2174000a919ea016385dac3cdb482ce2d21fee9f /libraries/Ethernet/Server.cpp | |
parent | a42326aba2fd9696a4b2e1239a5a222014056ff5 (diff) |
Adding write(str) and write(buf, size) methods to Print class and Ethernet library Client and Server classes. This allows sending a whole string or buffer at once, reducing the number of ethernet packets.
Diffstat (limited to 'libraries/Ethernet/Server.cpp')
-rw-r--r-- | libraries/Ethernet/Server.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libraries/Ethernet/Server.cpp b/libraries/Ethernet/Server.cpp index 351f838..d17a5d3 100644 --- a/libraries/Ethernet/Server.cpp +++ b/libraries/Ethernet/Server.cpp @@ -2,6 +2,7 @@ extern "C" { #include "types.h" #include "w5100.h" #include "socket.h" + #include "string.h" } #include "Ethernet.h" @@ -67,6 +68,16 @@ Client Server::available() void Server::write(uint8_t b) { + write(&b, 1); +} + +void Server::write(const char *str) +{ + write((const uint8_t *)str, strlen(str)); +} + +void Server::write(const uint8_t *buffer, size_t size) +{ accept(); for (int sock = 0; sock < MAX_SOCK_NUM; sock++) { @@ -74,7 +85,7 @@ void Server::write(uint8_t b) if (EthernetClass::_server_port[sock] == _port && client.status() == SOCK_ESTABLISHED) { - client.write(b); + client.write(buffer, size); } } -}
\ No newline at end of file +} |