Arduino UNO with Arduino wifi shield "No Socket Available" error

Hi,
I am trying to make an Arduino logger with a phpMyAdmin server, but after it runs 4 HTTP GET requests the Arduino says that there is an error "No Socket Available".

Can anyone please send me a solution for this error?

Many Thanks.

I am trying to make an Arduino logger with a phpMyAdmin server

phpMyAdmin is a script that presents a user interface on a browser that allows the user to manipulate MySQL databases.

It will NOT be the basis of your Arduino logger.

Can anyone please send me a solution for this error?

Once you accept a client connection, you must properly handle the client request AND close the socket. If you don't, the socket remains in use. There are only 4 sockets available.

Thanks for the reply,
This is my Request:
if (client.connect(server, 80)) {
i+=1;
client.println("GET /write_data.php?hue=1000&tmp=999.9&ID=001");
Serial.print("\nconnecting");
client.println(); // Empty line
client.println(); // Empty line

if (client.available() && status == WL_CONNECTED) {
char c = client.read();
Serial.write(c);
client.flush();
client.stop();
}

}

can you please review?

Many Thanks.

 if (client.available()  && status == WL_CONNECTED) {
      char c = client.read();
      Serial.write(c);
      client.flush();
      client.stop();
    }

If the server generated a response, and that response arrived within nanoseconds, read ONE character, and then shut down the client. That is NOT how to deal with the server response.

   while(client.connected())
   {
      while(client.available() > 0)
      {
         char c = client.read();
         Serial.print(c);
      }
   }

Once you have read the complete server response, the connection will be closed automatically, and the socket closed.

So it needs to look like this?

if (client.connect(server, 80)) {
client.println("GET /write_data.php?hue=1000&tmp=999.9&ID=001");
Serial.print("\nconnecting");
client.println(); // Empty line
client.println(); // Empty line

while(client.connected())
{
while(client.available() > 0)
{
char c = client.read();
Serial.print(c);
}
}
}

This whole code is inside of the loop void do I need to move some of it to the setup void?

GuyYanai:
This whole code is inside of the loop void do I need to move some of it to the setup void?

Tell me what you would call this:

int analogRead(int whichPin)
{
   int val = 0;
   // Do something
   return val;
}

It is NOT an int.

Your code doesn't have any voids, either.

It has FUNCTIONS.

All the code in the snippet goes in the loop() function.