Hi,
I'm trying to use my arduino ethernet like a client and a Java program like my server, I use the example committed by arduino and it function, The problem is that I need send more than 1 message and when I try to send a mensagge in the loop block It doesn't function, What should I do ??
There is my code
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
byte server[] = { 10, 10, 10, 10 };
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("H");
} else {
Serial.println("connection failed");
}
}
void loop()
{
if (client.available()) {
char c = client.read();
Serial.print(c);
if(c=='H'){
delay(1000);
client.write("H");
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
}