@@ -8,19 +8,19 @@ extern "C" {
88#include " Arduino.h"
99
1010#include " Ethernet.h"
11- #include " Client .h"
12- #include " Server .h"
11+ #include " EthernetClient .h"
12+ #include " EthernetServer .h"
1313#include " Dns.h"
1414
15- uint16_t Client ::_srcport = 1024 ;
15+ uint16_t EthernetClient ::_srcport = 1024 ;
1616
17- Client::Client () : _sock(MAX_SOCK_NUM) {
17+ EthernetClient::EthernetClient () : _sock(MAX_SOCK_NUM) {
1818}
1919
20- Client::Client (uint8_t sock) : _sock(sock) {
20+ EthernetClient::EthernetClient (uint8_t sock) : _sock(sock) {
2121}
2222
23- int Client ::connect (const char * host, uint16_t port) {
23+ int EthernetClient ::connect (const char * host, uint16_t port) {
2424 // Look up the host first
2525 int ret = 0 ;
2626 DNSClient dns;
@@ -35,7 +35,7 @@ int Client::connect(const char* host, uint16_t port) {
3535 }
3636}
3737
38- int Client ::connect (IPAddress ip, uint16_t port) {
38+ int EthernetClient ::connect (IPAddress ip, uint16_t port) {
3939 if (_sock != MAX_SOCK_NUM)
4040 return 0 ;
4141
@@ -54,7 +54,7 @@ int Client::connect(IPAddress ip, uint16_t port) {
5454 if (_srcport == 0 ) _srcport = 1024 ;
5555 socket (_sock, SnMR::TCP, _srcport, 0 );
5656
57- if (!::connect (_sock, ip. raw_address ( ), port)) {
57+ if (!::connect (_sock, rawIPAddress (ip ), port)) {
5858 _sock = MAX_SOCK_NUM;
5959 return 0 ;
6060 }
@@ -70,15 +70,15 @@ int Client::connect(IPAddress ip, uint16_t port) {
7070 return 1 ;
7171}
7272
73- size_t Client ::write (uint8_t b) {
73+ size_t EthernetClient ::write (uint8_t b) {
7474 return write (&b, 1 );
7575}
7676
77- size_t Client ::write (const char *str) {
77+ size_t EthernetClient ::write (const char *str) {
7878 return write ((const uint8_t *) str, strlen (str));
7979}
8080
81- size_t Client ::write (const uint8_t *buf, size_t size) {
81+ size_t EthernetClient ::write (const uint8_t *buf, size_t size) {
8282 if (_sock == MAX_SOCK_NUM) {
8383 setWriteError ();
8484 return 0 ;
@@ -90,13 +90,13 @@ size_t Client::write(const uint8_t *buf, size_t size) {
9090 return size;
9191}
9292
93- int Client ::available () {
93+ int EthernetClient ::available () {
9494 if (_sock != MAX_SOCK_NUM)
9595 return W5100.getRXReceivedSize (_sock);
9696 return 0 ;
9797}
9898
99- int Client ::read () {
99+ int EthernetClient ::read () {
100100 uint8_t b;
101101 if ( recv (_sock, &b, 1 ) > 0 )
102102 {
@@ -110,11 +110,11 @@ int Client::read() {
110110 }
111111}
112112
113- int Client ::read (uint8_t *buf, size_t size) {
113+ int EthernetClient ::read (uint8_t *buf, size_t size) {
114114 return recv (_sock, buf, size);
115115}
116116
117- int Client ::peek () {
117+ int EthernetClient ::peek () {
118118 uint8_t b;
119119 // Unlike recv, peek doesn't check to see if there's any data available, so we must
120120 if (!available ())
@@ -123,12 +123,12 @@ int Client::peek() {
123123 return b;
124124}
125125
126- void Client ::flush () {
126+ void EthernetClient ::flush () {
127127 while (available ())
128128 read ();
129129}
130130
131- void Client ::stop () {
131+ void EthernetClient ::stop () {
132132 if (_sock == MAX_SOCK_NUM)
133133 return ;
134134
@@ -148,22 +148,22 @@ void Client::stop() {
148148 _sock = MAX_SOCK_NUM;
149149}
150150
151- uint8_t Client ::connected () {
151+ uint8_t EthernetClient ::connected () {
152152 if (_sock == MAX_SOCK_NUM) return 0 ;
153153
154154 uint8_t s = status ();
155155 return !(s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::FIN_WAIT ||
156156 (s == SnSR::CLOSE_WAIT && !available ()));
157157}
158158
159- uint8_t Client ::status () {
159+ uint8_t EthernetClient ::status () {
160160 if (_sock == MAX_SOCK_NUM) return SnSR::CLOSED;
161161 return W5100.readSnSR (_sock);
162162}
163163
164164// the next function allows us to use the client returned by
165- // Server ::available() as the condition in an if-statement.
165+ // EthernetServer ::available() as the condition in an if-statement.
166166
167- Client ::operator bool () {
167+ EthernetClient ::operator bool () {
168168 return _sock != MAX_SOCK_NUM;
169169}
0 commit comments