Unable to connect ethernet shield to internet

Hi, i am trying to connect arduino to twitter using ethernet sheild. But i am unable to connect to the website. I think the arduino is getting an IP assigned , but i think the problem is at client.connect() function. pls help me. here is my code

#include <SPI.h>
#include <Ethernet.h>
	byte mac[]      = {  0x90, 0xA2, 0xDF, 0xC4, 0x70, 0x69 };  // MAC Address of Arduino Ethernet Shield
        byte ip[]       = { 192,168,1,177 };                       // IP assigned to arduino
        byte gateway[]  = { 192,168,1,1 };                          // Gateway address
        byte subnet[]   = { 255,255,255,0 };                        // Subnet Mask address
	byte server[]   = {199, 59,  148, 10 };                     // IP address of Twitter

        EthernetClient client;

	void setup()
                Serial.println("Program Initailising...");
		Ethernet.begin(mac, ip, subnet, gateway);

	void loop()
	{                if(client.connect(server,80))
                        client.println("GET http://www.twitter.com/statuses/user_timeline/HAutomation.rss HTTP/1.0");  // Senting an GET request to Twitter
                        Serial.println("Unable to connect to Twitter");
                  // if there are incoming bytes available 
  // from the server, read them and print them:
                if (client.available()) {
                char c = client.read();

  // if the server's disconnected, stop the client:
                if (!client.connected()) {


If you are using Arduino 1.0 then the arguments to Ethernet.begin() have changed. Your best bet is to pass only the MAC address and let DHCP assign everything else.

i tried that, when ethernet.begin() has only mac as its argument, it took a little more time to disconnect, otherwise it disconnects fast

Do not send the URL in the GET, just the file.

              client.println("GET /statuses/user_timeline/HAutomation.rss HTTP/1.0"); 
               Serial.println("Unable to connect to Twitter");

Perhaps File->Examples->Ethernet->TwitterClient would be a good starting point.

thaks guys. But the problem is with the client.connect(server,80). Its always returning false no matter what

Can you ping the shield ip from a localnet computer? ping

edit: The correct format for the begin function is: Ethernet.begin(mac, ip, dns, gateway, subnet); or if you do not use dns, you can use the gateway for the dns server ip Ethernet.begin(mac, ip, gateway, gateway, subnet);

ya, i can ping the arduino. But the exection of of client.connect() is not working correctly. Its always returning a FALSE no matter what

What is the ip address (edit: and subnet/gateway) of the localnet computer you used to ping the Arduino? Does it have internet access?

Do you have a localnet web server you can test with? Maybe that would help get the bugs out.

i havent set up a local server in my computer. How can i do it and how can i filter the bugs with the server??

If you use Windows, then IIS is the web server software. I use WinXP, and install it using Control panel - Add or Remove Programs - Add/Remove Windows Components - Internet Information Services

If you use Linux, then Apache is the web server. Usually, your distro will have a pre-compiled version in the repository for your flavor of Linux.

ok, after that i have to change the web address to localhost and then check whether i got the connection or not??

ok, after that i have to change the web address to localhost and then check whether i got the connection or not??

You need to change the server address on the Arduino to the localnet ip of your new server.

You did not answer the question about the localnet computer you are using (your new server now?). What ip/subnet/gateway does it have?

i am using ubuntu, so am planned to install an apache server,

is there anyway i can communicate with the arduino through the ethernet port of my system, using a C, C++ or any other languages. I am trying to read and respond to the arduino from the computer now

I modified Linux telnet server code written in C that I found on the internet. It wasn't easy. The Arduino end was the easy part.