-
Couldn't load subscription status.
- Fork 5
Ethernetclient::available()
André Dumas edited this page Dec 6, 2012
·
4 revisions
Returns the number of bytes ready to be read by the client.
This method emulates the Arduino Client available() for GorillaBuilderz WiFi.
client.available()
None
The number of bytes ready to be read.
#include <SPI.h>
#include <Transport.h>
#include <WizFi210.h>
#include <GBEthernet.h>
#include <GBIMAC.h>
GBIMAC macReader(A1);
byte mac[MAC_LENGTH];
IPAddress server(74,125,237,114); // Google
EthernetClient client;
void setup() {
Serial.begin(115200);
Serial.println("GorillaBuilderz Arduino WebClient for WiFi Shield");
Serial.println("Initialising modem and ataching to network...");
// NOTE: If you need to redefine the IO to your wifi shield call this BEFORE you execute any Ethernet* methods
WizFi210::create(10, 2, 5, 6);
Ethernet.ssid("BatPhone");
Ethernet.passphrase("password");
macReader.read(mac);
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
for(;;)
;
}
delay(1000);
Serial.println("connecting...");
if (client.connect(server, 80)) {
Serial.println("connected");
client.println("GET /search?q=arduino HTTP/1.0");
client.println();
}
else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}