Ethernet Shield. Reading from soket and sleeping.

Does arduino sleep when I try to read from Client and cliend do not write me?

In loop I see this :

void loop()
  Client client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean current_line_is_blank = true;
    while (client.connected()) {
      if (client.available()) {
        char c =;
        // if we've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so we can send a reply
        if (c == '\n' && current_line_is_blank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          // print all the files, use a helper to keep it clean
          //ListFiles(client, 0);
          ListFiles(client, 0);
        if (c == '\n') {
          // we're starting a new line
          current_line_is_blank = true;
        } else if (c != '\r') {
          // we've gotten a character on the current line
          current_line_is_blank = false;
    // give the web browser time to receive the data

char c =;

But if I need do something else in this time(if I need read no more than 1-2 seconds)??? May be my arduino needs only one time in hour? And all other time I do other work! And I can not sleep dozen of seconds!

It is big big question.

On PC I should make thread, and solve this problem, but on Arduino I do not belive how to solve it if it is true, and is sleeping!

Is it true? I can not check it, I have not Shield!

Please, tell me, is it true? Arduino sleep while read sleep?

Arduino sleep while read sleep?

No, the Arduino does not sleep while it is waiting for data.

      if (client.available()) {

This code is checking to see that there is data to be read before is called, so, should not block.

Yes man! We are happy.

Question 2.

I heard Ethernet shield can keep 4 connection in the same time. Is it really?

Question 2.1

Can Arduino execute several actions in the same time? (I hope it meants the question: has Arduino threads!?)

Yes, the shield can have up to 4 connections open at once. It can only service one at a time.

No, Arduino does not have threads. It's a micro-controller with no OS. How could it have threads?