Ethernet communication

I am trying to send from the server to the ethernet client(s). But the clients seems nothing to received. The aim of the project is to control all the clients from the server.

server

#include <Ethernet.h>
#include <SPI.h>

int i;
char reader [5];

byte mac[] = { 0xEE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 111 };

EthernetServer server = EthernetServer(80);
 
void setup()
{
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);  
  pinMode(13,OUTPUT);
  delay(1000);  
}

void loop()
{ 
  EthernetClient client = server.available();
  if (client == true) { 
    // read bytes from the incoming client and write them back
    // to any clients connected to the server:
    reader[0]=client.read();
      if(reader[0]=='A') 
      {
        for(i=1; i<10; i++) 
        {
          reader[i]=client.read();
          delay(2);
        }
      } 
   }
   if (Serial.available() > 2) {
     for(i=0; i<10; i++) 
     {
      reader[i]=Serial.read();
      delay(2);
    }
  }

  if(reader[0]=='1' &&reader[1]=='O' &&reader[2]=='N')
  digitalWrite(13,HIGH);
  if(reader[0]=='1' &&reader[1]=='O' &&reader[2]=='F')
  digitalWrite(13,LOW);
  if(reader[0]=='2' &&reader[1]=='O' &&reader[2]=='N')
  server.print("2ON");
  if(reader[0]=='2' &&reader[1]=='O' &&reader[2]=='F' &&reader[3]=='F')
  server.print("2OFF");
  if(reader[0]=='A' &&reader[1]=='O' &&reader[2]=='N')
  Serial.println("LED ON ARDUINO 2 IS ON");
  if(reader[0]=='A' && reader[1]=='O' &&reader[2]=='F' &&reader[3]=='F')
  Serial.println("LED ON ARDUINO 2 IS OFF");

  for(i=0; i<10; i++)
  reader[i]=0; // clear the buffer
}

client

#include <Ethernet.h>
#include <SPI.h>

int i;
char reader[10];


byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 110 };
byte server[] = { 192, 168, 1, 111 };

EthernetClient client;

void setup()
{
  pinMode(4,OUTPUT);
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  
  delay(1000);
  
  //Serial.println("connecting...");
  
 /* if (client.connect(server, 80)) {
    Serial.println("**CLIENT** connected");
    client.println();
  } else {
    Serial.println("**CLIENT** connection failed");
  }*/
}

void loop()

{
  if (client.available() && client.connected()) 
  {
    for (i=0; i<10; i++) 
    {
      reader[i]=client.read();
      delay(2);
    }
  }
  
  if( reader[0] =='2' &&reader[1]=='O' &&reader[2]=='N') 
  {
   digitalWrite(4,HIGH);
   delay(500);
   client.write("AON");
  }

  if( reader[0]=='2' &&reader[1]=='O' &&reader[2]=='F' &&reader[3]=='F') 
  {
   digitalWrite(4,LOW);
   delay(500);
   client.write("AOFF");
  }
    
  for(i=0; i<10; i++)
    reader[i]=0;    
}

There are a few things wrong with your sketches.

The client must send a request.
The server responds to the client request using client.print() or client.write().
The server closes the connection with client.stop() when finished sending packets.
The client then closes its end of the connection with client.stop().

I see none of this happening in your sketches. You might want to search the forum for client and server code by zoomkat. His code is pretty good. Get the communication working first. Then add the controls.

At this moment sending data to the client is working. Thanks for reporting to look at zoomkat sketches. They are very helpful.
I still am thinking what's the best way sending from the server to the client.
Now I just do a client.print() with a constant value

server

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = { 0xEE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 111 };

EthernetServer server = EthernetServer(80);
 
void setup()
{
  Ethernet.begin(mac, ip);
  server.begin();
  Serial.begin(9600);  
  pinMode(4,OUTPUT);
  delay(1000);  
}

void loop()
{  
   
  EthernetClient client = server.available();
  if (client) {    
    while (client.connected()) {
      if (client.available()) {
    
      client.print("on");
        
      }
          delay(1);
          //stopping client
          client.stop();

        }
      }
    }

client

#include <Ethernet.h>
#include <SPI.h>

char reader[2];
int i;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 1, 110 };
byte server[] = { 192, 168, 1, 111 };


EthernetClient client;

void setup()
{
  pinMode(4,OUTPUT);
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
  delay(1000);
}

void loop()

{  
   if (client.connect(server, 80)) 
   {
    Serial.println("connected");
    client.println();
   } else {
    Serial.println("connection failed");
    Serial.println();
  }

  while(client.connected() && !client.available()) delay(1); //waits for data
  while (client.connected() || client.available()) //connected or data available
  {
    for(i=0; i<2; i++)
    {
      reader[i] = client.read();
    } 
    Serial.print(reader[0]);
    Serial.print(reader[1]);
    
    if ( reader[0] == 'o' && reader[1] == 'n' )
    {
      digitalWrite(4, HIGH);
    } 
    
     if ( reader[0] == 'o' && reader[1] == 'f' )
    {
      digitalWrite(4, HIGH);
    } 
    
  }
  
  Serial.println();
  Serial.println("disconnecting.");
  Serial.println("==================");
  Serial.println();
  client.stop();
}