@@ -8,19 +8,19 @@ extern "C" {
8
8
#include " Arduino.h"
9
9
10
10
#include " Ethernet.h"
11
- #include " Client .h"
12
- #include " Server .h"
11
+ #include " EthernetClient .h"
12
+ #include " EthernetServer .h"
13
13
#include " Dns.h"
14
14
15
- uint16_t Client ::_srcport = 1024 ;
15
+ uint16_t EthernetClient ::_srcport = 1024 ;
16
16
17
- Client::Client () : _sock(MAX_SOCK_NUM) {
17
+ EthernetClient::EthernetClient () : _sock(MAX_SOCK_NUM) {
18
18
}
19
19
20
- Client::Client (uint8_t sock) : _sock(sock) {
20
+ EthernetClient::EthernetClient (uint8_t sock) : _sock(sock) {
21
21
}
22
22
23
- int Client ::connect (const char * host, uint16_t port) {
23
+ int EthernetClient ::connect (const char * host, uint16_t port) {
24
24
// Look up the host first
25
25
int ret = 0 ;
26
26
DNSClient dns;
@@ -35,7 +35,7 @@ int Client::connect(const char* host, uint16_t port) {
35
35
}
36
36
}
37
37
38
- int Client ::connect (IPAddress ip, uint16_t port) {
38
+ int EthernetClient ::connect (IPAddress ip, uint16_t port) {
39
39
if (_sock != MAX_SOCK_NUM)
40
40
return 0 ;
41
41
@@ -54,7 +54,7 @@ int Client::connect(IPAddress ip, uint16_t port) {
54
54
if (_srcport == 0 ) _srcport = 1024 ;
55
55
socket (_sock, SnMR::TCP, _srcport, 0 );
56
56
57
- if (!::connect (_sock, ip. raw_address ( ), port)) {
57
+ if (!::connect (_sock, rawIPAddress (ip ), port)) {
58
58
_sock = MAX_SOCK_NUM;
59
59
return 0 ;
60
60
}
@@ -70,15 +70,15 @@ int Client::connect(IPAddress ip, uint16_t port) {
70
70
return 1 ;
71
71
}
72
72
73
- size_t Client ::write (uint8_t b) {
73
+ size_t EthernetClient ::write (uint8_t b) {
74
74
return write (&b, 1 );
75
75
}
76
76
77
- size_t Client ::write (const char *str) {
77
+ size_t EthernetClient ::write (const char *str) {
78
78
return write ((const uint8_t *) str, strlen (str));
79
79
}
80
80
81
- size_t Client ::write (const uint8_t *buf, size_t size) {
81
+ size_t EthernetClient ::write (const uint8_t *buf, size_t size) {
82
82
if (_sock == MAX_SOCK_NUM) {
83
83
setWriteError ();
84
84
return 0 ;
@@ -90,13 +90,13 @@ size_t Client::write(const uint8_t *buf, size_t size) {
90
90
return size;
91
91
}
92
92
93
- int Client ::available () {
93
+ int EthernetClient ::available () {
94
94
if (_sock != MAX_SOCK_NUM)
95
95
return W5100.getRXReceivedSize (_sock);
96
96
return 0 ;
97
97
}
98
98
99
- int Client ::read () {
99
+ int EthernetClient ::read () {
100
100
uint8_t b;
101
101
if ( recv (_sock, &b, 1 ) > 0 )
102
102
{
@@ -110,11 +110,11 @@ int Client::read() {
110
110
}
111
111
}
112
112
113
- int Client ::read (uint8_t *buf, size_t size) {
113
+ int EthernetClient ::read (uint8_t *buf, size_t size) {
114
114
return recv (_sock, buf, size);
115
115
}
116
116
117
- int Client ::peek () {
117
+ int EthernetClient ::peek () {
118
118
uint8_t b;
119
119
// Unlike recv, peek doesn't check to see if there's any data available, so we must
120
120
if (!available ())
@@ -123,12 +123,12 @@ int Client::peek() {
123
123
return b;
124
124
}
125
125
126
- void Client ::flush () {
126
+ void EthernetClient ::flush () {
127
127
while (available ())
128
128
read ();
129
129
}
130
130
131
- void Client ::stop () {
131
+ void EthernetClient ::stop () {
132
132
if (_sock == MAX_SOCK_NUM)
133
133
return ;
134
134
@@ -148,22 +148,22 @@ void Client::stop() {
148
148
_sock = MAX_SOCK_NUM;
149
149
}
150
150
151
- uint8_t Client ::connected () {
151
+ uint8_t EthernetClient ::connected () {
152
152
if (_sock == MAX_SOCK_NUM) return 0 ;
153
153
154
154
uint8_t s = status ();
155
155
return !(s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::FIN_WAIT ||
156
156
(s == SnSR::CLOSE_WAIT && !available ()));
157
157
}
158
158
159
- uint8_t Client ::status () {
159
+ uint8_t EthernetClient ::status () {
160
160
if (_sock == MAX_SOCK_NUM) return SnSR::CLOSED;
161
161
return W5100.readSnSR (_sock);
162
162
}
163
163
164
164
// 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.
166
166
167
- Client ::operator bool () {
167
+ EthernetClient ::operator bool () {
168
168
return _sock != MAX_SOCK_NUM;
169
169
}
0 commit comments