using GET function to poll server repeatedly

Hi,

I’m attempting to modify the Wifly_Webclient code to poll my server repeatedly to check for an updated value. The goal is to turn on/off a switch using my phone. For example “1” will represent the on position and “0” will represent the off position.

Currently, the code seems to print a the variable “c” value once and then retains that in memory and does not update. Could anyone make a suggestion how I can modify the code in order to poll the server?

Thanks

Andrew

// (Based on Ethernet's WebClient Example)

#include "WiFly.h"


#include "Credentials.h"


byte server[] = { 66, 96, xxx, xx }; // Google

//Client client(server, 80);

Client client("xxxxxxxxx.com", 80);

void setup() {

  Serial.begin(9600);

  WiFly.begin();

  if (!WiFly.join(ssid, passphrase)) {
    Serial.println("Association failed.");
    while (1) {
      // Hang on failure.
    }
    
  }
    Serial.println("Can u reach me ?");
    Serial.print("IP: ");
    Serial.println(WiFly.ip());
  

  Serial.println("connecting...");

//  if (client.connect()) {
  //  Serial.println("connected");
   // client.println("GET http://xxxxxxxxxxxxxx.com/testFile.txt");
    //client.println();
//  } 
  //else {
   // Serial.println("connection failed");
  }

char c = 'f';
int a = 0;
void loop() {
        
     while(a<5){
     client.connect();
     client.println("GET http://xxxxxxxxxx.com/testFile.txt\r\n");
     delay(5000);
     client.println();
     c = client.read();
     Serial.print(c);
     Serial.println();
     a=1+a;
     Serial.print(a);
     client.stop();
    }

    client.stop();    
  //  Serial.println("disconnecting.");    
  }

 // if (!client.connected()) {
  //  Serial.println();
 //   Serial.println("disconnecting.");
 //   client.stop();
 //   for(;;)
 //     ;
//  }