wifi web server code

Dear friends,

We are in the big trouble to make our wifi web server code to work as it is original code from arduino learning section as follows

#include <SPI.h>
#include <WiFi.h>
int iStatus = WL_IDLE_STATUS;
char szSsid[] = "S603-1"; // network SSID (name)
char szPass[] = "ipmsimk0827"; // network password

// webserver
WiFiServer server(80);
void setup(){
Serial.begin(9600);
fnConnectToAP();
// fnSendRequest();
fnStartServer();
}

void loop(){
fnWaitingRequest();
// fnReadData();
}

void fnStartServer(){
delay(1000);
server.begin();
}

void fnWaitingRequest(){
WiFiClient client = server.available();

if (client) {
Serial.println("new client comming");

boolean bCurrentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && bCurrentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println();
client.println("");
client.println("");
client.print("Hello World ");

client.println("");
break;
}
if (c == '\n') {
// you're starting a new line
bCurrentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
bCurrentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1000);

// close the connection:
client.stop();
Serial.println("client disonnected");
}

}
void fnConnectToAP(){
while ( iStatus != WL_CONNECTED) {
Serial.println("Connecting to network...");
Serial.print("SSID: ");
Serial.println(szSsid);
delay(1000);
iStatus = WiFi.begin(szSsid,szPass); // connect
}
Serial.print("Connected successfully. IP address:");
IPAddress myAddress = WiFi.localIP();
Serial.println(myAddress);
}

However, it is no working. We use both arduino wifi shield and arduino mega 2560. In the similation, it works on the tranfermation cmd and ping checking is fine but do not show the window out. Your urgently assist is much appreciated

void fnStartServer(){
  delay(1000);
  server.begin();
}

Do nothing for a while. Then, start the WiFi shield. The next function expects the shield to be read when it is called. Starting the shield, and then sticking your thumb up your ass for a while makes more sense.

However, it is no working.

The code certainly is. It may not be doing what you want, but that doesn't mean that it is not working.

You have not said what the code actually does. You have not said what you expect it to do. You have not explained how those two differ. Therefore, all we can do is wish you luck fixing the problem, whatever it is.

Did you upgrade the Wifi shield firmware?

edit You can check with this code addition.

 // check firmware version
 Serial.print(F("Firmware version: "));
 Serial.println(WiFi.firmwareVersion());