-
Couldn't load subscription status.
- Fork 5
Ethernetclient::stop()
André Dumas edited this page Dec 6, 2012
·
3 revisions
Diconnects from the server.
This method emulates the Arduino Client stop() for GorillaBuilderz WiFi.
client.stop()
None
None
#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(;;)
;
}
}