system
February 12, 2013, 9:21pm
1
Hello,
When trying to run a simple get program, I ran into issues while trying to process the get request.
In a simple nested loop example, like this:
while(client.connected()){
while (client.available()) {
char c = client.read();
Serial.println(c);
}
}
The client.connected() evaluates as true, but the client.available() -which returns how many bytes I have available for reading- returns 0. Why do I not have any available space? Do I need to use an SD card?
thanks
system
February 12, 2013, 9:23pm
2
Why do I not have any available space?
If connected() returns true, and available() returns 0, it means that the Arduino is waiting for the server to supply a response that can be read.
What are you connecting to? What GET request did you make? What response is that server/script returning?
The available() method says nothing about space.
system
February 12, 2013, 9:55pm
3
servername is: char servername[]="www.arduino.cc";
if (client.connect(servername, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /latest.txt HTTP/1.1");
client.println("Host: www.arduino.cc");
client.println("User-Agent: arduino-ethernet");
client.println("Connection: close");
client.println();
while(client.connected()) {
//Serial.println (client.connected());
Serial.println(client.available());
while (client.available()) {
// client.setTimeout(2000);
char c = client.read();
Serial.println(c);
}
}
I am just trying ot get the source from the page: http://www.arduino.cc/latest.txt
system
February 13, 2013, 11:56am
4
The Host, User-Agent, and Connection statements are not needed.
Do you have DNS enabled, outside that snippet? If not, you need to use IP addresses, not host names.
system
February 13, 2013, 10:40pm
5
sorry, apparently there are just problems between the wifi shield and mac OSX. Tried it on a windows machine and it worked. Thanks