@@ -40,6 +40,14 @@ EthernetServer server(23);
4040EthernetClient clients[4 ];
4141
4242void 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+
4351 // initialize the Ethernet device
4452 Ethernet.begin (mac, ip, myDns, gateway, subnet);
4553 // start listening for clients
@@ -63,7 +71,7 @@ void loop() {
6371 if (client) {
6472
6573 boolean newClient = true ;
66- for (byte i = 0 ; i < 4 ; i++) {
74+ for (byte i= 0 ; i < 4 ; i++) {
6775 // check whether this client refers to the same socket as one of the existing instances:
6876 if (clients[i] == client) {
6977 newClient = false ;
@@ -73,7 +81,7 @@ void loop() {
7381
7482 if (newClient) {
7583 // 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++) {
7785 if (!clients[i] && clients[i] != client) {
7886 clients[i] = client;
7987 // clear out the input buffer:
@@ -91,7 +99,7 @@ void loop() {
9199 // read the bytes incoming from the client:
92100 char thisChar = client.read ();
93101 // 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++) {
95103 if (clients[i] && (clients[i] != client)) {
96104 clients[i].write (thisChar);
97105 }
@@ -100,7 +108,7 @@ void loop() {
100108 Serial.write (thisChar);
101109 }
102110 }
103- for (byte i = 0 ; i < 4 ; i++) {
111+ for (byte i= 0 ; i < 4 ; i++) {
104112 if (!(clients[i].connected ())) {
105113 // client.stop() invalidates the internal socket-descriptor, so next use of == will allways return false;
106114 clients[i].stop ();
0 commit comments