Problem in making HTTP request using ethernet shield

Output :
"Connecting
Connected

Disconnection"

The problem being the webpage data is not read. I tried different pages like .html, .php but still the same response.

What I could infer from this is that if(client.available()) is getting FALSE. Please help.

#include <SPI.h>
#include <Ethernet.h>
char c;
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(74,125,232,128); // numeric IP for Google (no DNS)
char server[] ={ 127, 0, 0, 1}; // name address for Google (using DNS)

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");

// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /sooraj/index.php HTTP/1.1");
client.println("Host: localhost");
client.println("Connection: close");

} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}

void loop() {
// if there are incoming bytes available
// from the server, read them and print them:
if (client.available()) {
char c = client.read();
Serial.print(c);
}

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

client.stop();

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

localhost 127.0.0.1 is loopback name/address. the arduino doesn't run the server. use the real IP of the computer where the server runs

Juraj:
localhost 127.0.0.1 is loopback name/address. the arduino doesn't run the server. use the real IP of the computer where the server runs

I am a beginner to networking and arduino. Can you please explain. Did you mean that I should use the ipv4 address instead of local host ?

every device with TCP is localhost with address 127.0.0.1. It is the address or name for talking to it self over the TCP protocol loopback.

Juraj:
every device with TCP is localhost with address 127.0.0.1. It is the address or name for talking to it self over the TCP protocol loopback.

what change do I exactly have to make

IPAddress server(192, 168, 0, ???); <- set your server's real IP address, not the "me, myself and I" address

replace
client.println("Host: localhost");
with
client.print("Host: ");
client.println(server);

Juraj:

IPAddress server(192, 168, 0, ???); <- set your server's real IP address, not the "me, myself and I" address

replace
client.println("Host: localhost");
with
client.print("Host: ");
client.println(server);

I tried it, made the respective changes, but still it shows connects and disconnects without reading the file. Can you please debug this problem, its really important for my project.

This is my code

#include <SPI.h>
#include <Ethernet.h>
char c;

char server[] = { 192, 168,0,100};

// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

EthernetClient client;

void setup() {

Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
// give the Ethernet shield a second to initialize:
delay(1000);
Serial.println("connecting...");

// if you get a connection, report back via serial:
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("GET /sooraj/hello.html HTTP/1.1");
client.println("Host: ");
client.println(server);
client.println("Connection: close");
client.println();
} else {
// if you didn't get a connection to the server:
Serial.println("connection failed");
}
}

void loop() {

if (client.available()) {
char c = client.read();
Serial.print(c);
}

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

client.stop();

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

The output is :

Connecting..

Connected
Disconnecting..

My project deadline is here and its very urgent. Please help

change client.println("Host: ") to client.print("Host: ")
and change if (client.available()) to while (client.available()) {

The SparkFun Ethernet Shield, particularly the Wiznet W5100, can be a power-hungry little beast. It’s recommended that you use a power supply that can source at least 400mA. Powering the shield over USB will work in most cases, though it wouldn’t hurt to power your Arduino via a 9V wall-wart.

The W5100’s hunger for power will cause it and the 3.3V regulator to heat up. This is normal, especially when the chip is doing a lot of work. They should never get untouchable hot, but they might get too-hot-to-comfortably-leave-your-finger-on-for-extended-periods hot.