compile works and upload works but it doesn't preform like its supposed to

So I have a code that is supposed to, in the long run, take a variable from a website and have the Arduino use it to make an LED act like a PWM so I am currently trying to get it to connect to the website I’m not sure if I’m doing it correctly but from what I understand this code should print out "Couldn’t get a wifi connection"when it cant connect and “Connected to wifi. My address:” on the serial monitor when it can. I’m having the trouble that when it uploads it works fine but this is what shows up on the serial monitor so I don’t think its working correctly. I am a novice when it comes to programming and have been struggling to figure this out for a while.

Unable to connect: retrying (0)…
Unable to connect: retrying (2)…
Unable to connect: retrying (3)… connected!
connected!
connected!

this is my code

#include <Console.h>
#include <TextFinder.h>
#include <Bridge.h>
#include <WiFi.h>
#include <WiFiServer.h>

WiFiClient client;
TextFinder finder( client );
char ssid[] = "192.168.240.1";          //  your network SSID (name) 
char pass[] = "arduino";   // your network password
int status = WL_IDLE_STATUS;
WiFiServer server(80);

void setup() {

const char* server = "http://192.168.240.1/sd/serial";//this is supposed to define the server 
  Bridge.begin();
  Console.begin();
status = WiFi.begin(ssid, pass);
}

void loop() {
  client = server.available();
  if (client); {
    while (client.connected()); {
      if (client.available()) ;{
        char c = (char) client.read();}}}

//to see if its acctualy connecting 

 if ( status != WL_CONNECTED) { 
    Console.println("Couldn't get a wifi connection");
    while(true);
  } 
  else {
    server.begin();
    Console.print("Connected to wifi. My address:");
    IPAddress myAddress = WiFi.localIP();
    Console.println(myAddress);
  }
}

(deleted)

It's the ssid and the password of the Arduinos network which is where the website is I'm not sure if that's how you're supposed to do it but its the only idea I had left.

I'm 90% sure this is the SSID of your network unless you changed it:

When you first power on the Yún, it will create a WiFi network called ArduinoYun-XXXXXXXXXXXX. Connect your computer to this network.

oh my gosh your right thank you so much now does anyone know how to get it to work consistently with the serial monitor I can only get it to print a couple times before it stops connecting I've checked a few forums but I can't find a solution.

rcvolley:
oh my gosh your right thank you so much now does anyone know how to get it to work consistently with the serial monitor I can only get it to print a couple times before it stops connecting I've checked a few forums but I can't find a solution.

You need a boolean variable that says "i have already printed out the connection message and I don't need to do it again".