Ethernet Webclient 1.0 example problem with ip [SOLVED]

Hello, I have been using version 23 very happy but was thinking of upgrading to 1.0.
however i am having trouble with the webclient example cause you can no longer specify the ip of the arduino and the gateway of the router.

i have tried the following with the following error

/*
Web client

This sketch connects to a website (http://www.google.com)
using an Arduino Wiznet Ethernet shield.

Circuit:

  • Ethernet shield attached to pins 10, 11, 12, 13

created 18 Dec 2009
by David A. Mellis

*/

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte ip[] = { 192,168,1,177 };
byte gateway[] = { 192,168,1,1 };
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress server(173,194,33,104); // Google

// 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() {
// start the serial library:
Serial.begin(9600);
// start the Ethernet connection:
if (Ethernet.begin(mac, ip, gateway) == 0) {
//if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
for(;:wink:
;
}
// 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 /search?q=arduino HTTP/1.0");
client.println();
}
else {
// kf 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:
for(;:wink:
;
}
}

WebClient.cpp: In function 'void setup()':
WebClient:33: error: void value not ignored as it ought to be

thank you very much for your time.

The Ethernet.begin() format has changed. It causes some challenges when converting previous version code.

It now takes the following formats
void begin(uint8_t *mac_address, IPAddress local_ip);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway);
void begin(uint8_t *mac_address, IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);

Note all after just the ip have a dns server ip, then the gateway, then the subnet.

mmm...so what should this value be IPAddress dns_server
I dont understand. is that supposed to be the
IPAddress server(173,194,33,104); // Google

Normally, your router can take care of dns for clients, so I would try the same ip for both the gateway and dns server. That is how my routers issue dhcp settings. It issues its ip as the dns server. Otherwise, try the dns ip your localnet computers use in their settings.

Add: I was interrupted by work Here is an example.

Ethernet.begin(mac,ip,gateway,gateway);

it shows however this error...

if (Ethernet.begin(mac, ip, gateway, gateway) == 0) {

sketch_feb03a.cpp: In function 'void setup()':
sketch_feb03a:34: error: void value not ignored as it ought to be

That is a correct error. Only
Ethernet.begin(mac);
returns a value. All others (believe it or not!) are a void type. Use just
Ethernet.begin(mac,ip,gateway,gateway);

uppsss sorry for my stupid question then .
thats correct it solved the issue, however does not connect eventhough i am using same ip, gateway and server as in arduino 22 version

/*
  Web client
 
 This sketch connects to a website (http://www.google.com)
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 
 created 18 Dec 2009
 by David A. Mellis
 
 */

#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte ip[] = { 192,168,1,177 };
byte gateway[] = { 192,168,1,1 };
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

IPAddress server(173,194,33,104); // Google

// 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() {
  // start the serial library:
  Serial.begin(9600);
  // start the Ethernet connection:
 // if (Ethernet.begin(mac,ip,gateway,gateway) == 0) {
  Ethernet.begin(mac,ip,gateway,gateway);
  {
  //  Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
  //  for(;;)
  //    ;
  }
  // 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 /search?q=arduino HTTP/1.0");
    client.println();
  } 
  else {
    // kf 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:
    for(;;)
      ;
  }
}

This server is not answering today:
IPAddress server(173,194,33,104); // Google

This one is!
IPAddress server(74,125,227,115); // Google

haha i was just about to post that same thing.

IPAddress server(74,125,39,147); // Google

thank you so much SurferTim, you really helped me here. Hope i can convert my running projects to 1.0 without too much trouble.
thanks !!!

just came back to mark the issue as SOLVED and thank again SurferTim as now i have solved my ethernet shield problem in my project.

however, a quick question.
I am using a modified version of EEPROM library to be able to store int values directly.

below is the whole cpp code, however I get a problem in this line:

	eeprom_write_byte((unsigned char *) address, (byte) (value >> 8) & 0xFF);
	eeprom_write_byte((unsigned char *) address+1, (byte) value & 0xFF );

..._Arduino\arduino-1.0\libraries\EEPROM\EEPROM.cpp: In member function 'void EEPROMClass::writeInt(int, int)':
..._Arduino\arduino-1.0\libraries\EEPROM\EEPROM.cpp:56: error: 'Byte' was not declared in this scope
...\arduino-1.0\libraries\EEPROM\EEPROM.cpp:57: error: expected `)' before 'value'

the byte is doing a cast,right? why the error? maybe i need to include "WConstants.h"??
I was getting an error with that included but commenting it solved it, dont know if its related to the BYTE issue.

i followed this bug solution but did not work
http://code.google.com/p/arduino/issues/detail?id=682

thanks for any help

/******************************************************************************
 * Includes
 ******************************************************************************/

#include <avr/eeprom.h>
//#include "WConstants.h"
#include "EEPROM.h"

/******************************************************************************
 * Definitions
 ******************************************************************************/

/******************************************************************************
 * Constructors
 ******************************************************************************/

/******************************************************************************
 * User API
 ******************************************************************************/

uint8_t EEPROMClass::read(int address)
{
	return eeprom_read_byte((unsigned char *) address);
}
int EEPROMClass::readInt(int address)
{
	return ( eeprom_read_byte((unsigned char *) address) << 8 ) + eeprom_read_byte((unsigned char *) address+1);
}

void EEPROMClass::write(int address, uint8_t value)
{
	eeprom_write_byte((unsigned char *) address, value);
}

void EEPROMClass::writeInt(int address, int value)
{
	eeprom_write_byte((unsigned char *) address, (byte) (value >> 8) & 0xFF);
	eeprom_write_byte((unsigned char *) address+1, (byte) value & 0xFF );
}

EEPROMClass EEPROM;

I don't know if it knows about 'byte' types. Normally, it is uint8_t.

eeprom_write_byte((unsigned char *) address, (uint8_t) (value >> 8) & 0xFF);
eeprom_write_byte((unsigned char *) address+1, (uint8_t) value & 0xFF );

Give that a try.

//#include "WConstants.h"

Why is this commented out?

SuferTim that seems to fix the problem. although now i have an incompatibility with RTC so need to fix it and see if all compiles, ill report back if it solved the issue.

Paul I got an error in arduino1.0 calling Wconstants.h, commenting it remove the error and did not throw any new errors. is this normal?

btw, anyone know if a dead easy RTC library for arduino1.0, one where i can just call RTC.seconds() etc to get the values?

I got an error in arduino1.0 calling Wconstants.h, commenting it remove the error and did not throw any new errors. is this normal?

I would have replaced it with Arduino.h. There was, apparently, a reason that the library included that file in the first place.