TCP connection CPU usage, multiple signals? I'm connecting a client (java program) to an arduino (server). What I want to know is, how high the CPU usage is, and what to do if there are no clients that are trying to connect to arduino? Should I make a delay?

My code looks like this:

EthernetClient client = server.available();

if(client){
    Serial.println("Connected");
    server.write("Hello\n");

    //check if client is still connected
    while (client.connected()){
        Serial.println("Still there");
        delay(2000);
       //check if client received any data
       if(client.available()){
           //read message from client
     }
  }
} else {
     Serial.println("Nope");
     server.write("Hello\n");
     ???????????? delay(2000); ??????????????
}


Thank you for your help.
As the Arduino typically has no demand-based clock scaling, or alternate threads of comparable priority you can schedule, there's really little point in using a delay (which is implemented as a busy-wait) rather than a tight loop - really, the primary appropriate reason would be to reduce the frequency of status output.

However, if you want to design a power-efficient system, you could consider sleeping the CPU between checking if there is anything worthwhile to do, or until an interrupt indicates that there is.  This is not something which delay() will take care of for you, so it is a fair amount of extra work and testing to get right, but it can be very worthwhile if running from batteries.

If your application is not particularly intensive you can also configure the clock divider fuse and slow the chip down generally.