No Socket Available...?

Hey guys, i'm quite troubled by this problem im having with my Arduino Uno + Wifi shield set up. I created a scale and i'm trying to send values from the arduino to my database everytime i press the push button. However, after about 3-4 times of successfully sending the value, the next value would not send and it'd give me "No Socket Available". I've tried multiple things that some of the members on the board have suggested like adding a delay after sending the values, or using client.flush but still the problem persist.

Any help would be much appreciated!!

Here are portions of the code im using to send the HTTP request

void readData(float offset)
{
Serial.println("Reading the weight....");
delay(1000);

int sensorvalue = analogRead(A0);
Serial.print("THE OFFSET VOLTAGE IS ");
Serial.println(offset,8);
float voltage = sensorvalue*(5/1023.0);
Serial.print("the voltage is ");
Serial.println(voltage,8);
float grams = (voltage - offset)/0.0039664;
Serial.print("the grams is ");
Serial.println(grams);

//MAKE HTTP REQUEST@!@@!
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected to server");
delay(1000);
Serial.println("Sending weight to database... please wait");
delay(1000);
client.print("GET /recipes/scaledata/");
client.print(grams);
client.println(" HTTP/1.1");
client.println("Host: www.google.com");
client.println("Connection: close");
client.println();
delay(1000);
}
else
Serial.println("Connection failed.");

void loop() {
// if there are incoming bytes available
// from the server, read them and print them:
while(client.connected()) {

while (client.available()&&status) {
char c = client.read();
Serial.write(c);

delay(1000);
}
}
client.stop();
// if the server's disconnected, stop the client:
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting from server.");
client.flush();
client.stop();

// do nothing forevermore:
while(true);
}
}

Thanks :slight_smile:

while (client.available()&&status) {
   char c = client.read();
   Serial.write(c);

   delay(1000);
 }

I
t

w
i
l
l

t
a
k
e

a

l
o
n
g

t
i
m
e

t
o

r
e
a
d

t
h
e

r
e
s
p
o
n
s
e

w
i
t
h

t
h
a
t

s
t
u
p
i
d

d
e
l
a
y

i
n

t
h
e
r
e
.

GET RID OF IT!

Here are portions of the code im using to send the HTTP request

Here are portions of my answer.

You need to fix lines ... where the problem is that ... Once you do that, eveything should work.

Hope that helps.

Yes, we can't fix code we can't see.

Hey thanks for the reply PaulS, where did you say the problem is? I still can't get it to work heheh

where did you say the problem is?

The problem is that you need to take your snippets to http://snippets-r-us.com.