#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xEF, 0xED };
byte ip[] = {192, 168, 0, 10 };
int CurrentTime = 0;
const int TimeOutMax = 6000;
boolean DebugMode = true;
Server server = Server(23);
void setup()
{
pinMode(StatusLED, OUTPUT); // sets the digital pin as output
digitalWrite(StatusLED, HIGH);
pinMode(Learner, INPUT);
pinMode(IR1, OUTPUT);
pinMode(IR2, OUTPUT);
pinMode(IR3, OUTPUT);
pinMode(IR4, OUTPUT);
digitalWrite(StatusLED, LOW);
delay(200);
Ethernet.begin(mac, ip);
server.begin();
digitalWrite(StatusLED, HIGH);
Serial.begin(9600);
}
void loop()
{
Client client = server.available();
if (client)
{
if (DebugMode)
{
Serial.println("Connected");
}
byte ReadyChar;
ReadyChar = client.read();
if (ReadyChar == 0)
{
}
if (ReadyChar == 255)
{
client.write(255);
GetCommandData(client);
client.stop();
}
}
else
{
if (DebugMode)
{
Serial.println("Not Connected");
}
}
}
There is more too it if you want to see it all, but there is normally 10 seconds between connections (sometimes a little less or more). I timed the code to get from the Serial.println("Not Connected"); back to that statement after it connects transfers data and does it thing then back to saying "Not Connected" normally takes about 400 ms.