client.connect
hello
i have code exemple
#include <ethernet.h>
#include <spi.h>
byte mac[] = { 0x90, 0xa2, 0xda, 0x0f, 0x45, 0x1a };
byte ip[] = { 172, 20, 30, 50 };
byte server[] = { 64, 233, 187, 99 }; // google
ethernetclient client;
void setup()
{
ethernet.begin(mac, ip);
serial.begin(9600);
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(;
;
}
}
and dont pass client.connect
can me?
this not code, in code have same problem.
the client works in void loop? not in void setup?
i take code here:
http://arduino.cc/en/reference/clientconnect
i have code exemple
#include <ethernet.h>
#include <spi.h>
byte mac[] = { 0x90, 0xa2, 0xda, 0x0f, 0x45, 0x1a };
byte ip[] = { 172, 20, 30, 50 };
byte server[] = { 64, 233, 187, 99 }; // google
ethernetclient client;
void setup()
{
ethernet.begin(mac, ip);
serial.begin(9600);
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(;

;
}
}
and dont pass client.connect
can me?
this not code, in code have same problem.
the client works in void loop? not in void setup?
i take code here:
http://arduino.cc/en/reference/clientconnect
quote
this not code
then why did was?
quote
i have code
make mind.
quote
the client works in void loop? not in void setup?
there no voids in code. there functions.
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > client.connect
arduino
Comments
Post a Comment