@@ -40,6 +40,14 @@ EthernetServer server(23);
40
40
EthernetClient clients[4 ];
41
41
42
42
void setup () {
43
+ // You can use Ethernet.init(pin) to configure the CS pin
44
+ // Ethernet.init(10); // Most Arduino shields
45
+ // Ethernet.init(5); // MKR ETH shield
46
+ // Ethernet.init(0); // Teensy 2.0
47
+ // Ethernet.init(20); // Teensy++ 2.0
48
+ // Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
49
+ // Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
50
+
43
51
// initialize the Ethernet device
44
52
Ethernet.begin (mac, ip, myDns, gateway, subnet);
45
53
// start listening for clients
@@ -63,7 +71,7 @@ void loop() {
63
71
if (client) {
64
72
65
73
boolean newClient = true ;
66
- for (byte i = 0 ; i < 4 ; i++) {
74
+ for (byte i= 0 ; i < 4 ; i++) {
67
75
// check whether this client refers to the same socket as one of the existing instances:
68
76
if (clients[i] == client) {
69
77
newClient = false ;
@@ -73,7 +81,7 @@ void loop() {
73
81
74
82
if (newClient) {
75
83
// check which of the existing clients can be overridden:
76
- for (byte i = 0 ; i < 4 ; i++) {
84
+ for (byte i= 0 ; i < 4 ; i++) {
77
85
if (!clients[i] && clients[i] != client) {
78
86
clients[i] = client;
79
87
// clear out the input buffer:
@@ -91,7 +99,7 @@ void loop() {
91
99
// read the bytes incoming from the client:
92
100
char thisChar = client.read ();
93
101
// echo the bytes back to all other connected clients:
94
- for (byte i = 0 ; i < 4 ; i++) {
102
+ for (byte i= 0 ; i < 4 ; i++) {
95
103
if (clients[i] && (clients[i] != client)) {
96
104
clients[i].write (thisChar);
97
105
}
@@ -100,7 +108,7 @@ void loop() {
100
108
Serial.write (thisChar);
101
109
}
102
110
}
103
- for (byte i = 0 ; i < 4 ; i++) {
111
+ for (byte i= 0 ; i < 4 ; i++) {
104
112
if (!(clients[i].connected ())) {
105
113
// client.stop() invalidates the internal socket-descriptor, so next use of == will allways return false;
106
114
clients[i].stop ();
0 commit comments