etracer,
Below is what i came up with for a simple example that displays the problem
when the connection is made the elapsed time is always roughly 120ms
when it fails it is always about 32180ms
so there is some sort of time out built into the connect function. i don't know enough about C to figure this all out. all i can do is give sample code to help point smarter guys in the right direction.
let me know your thoughts on this when you have a chance to look at it
Thanks
Jeff
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {
192, 168, 0, 54 };
byte subnet[] = {
255, 255, 255, 0 };
byte gateway[] = {
192, 168, 0, 1 };
byte server[] = {
74, 86, 153, 136 }; // btbsw
Client client(server, 80);
int failures = 0;
unsigned long time;
void setup()
{
Ethernet.begin(mac, ip, gateway, subnet);
Serial.begin(9600);
Serial.println("Connecting...");
delay(1000);
}
void loop()
{
Serial.println("001-Connect");
time = millis();
if (client.connect()) {
Serial.println("002-Waiting to be connected...");
Serial.print("Elapsed time(ms) = ");
Serial.println(millis()-time, DEC);
while (!client.connected()) delay(50); // wait for byte
Serial.println("003-Connection established");
Serial.println("004-Sending GET request");
client.println("GET /~latenigh/test.php HTTP/1.0");
client.println();
Serial.println("005-Waiting for response...");
while (client.available() == 0) delay(50); // wait for byte
Serial.println("006-Received something");
Serial.println("<Begin Response>");
while (client.available() != 0) Serial.print((char)client.read());
Serial.println();
Serial.println("<End Response>");
Serial.println("007-Finished getting response");
Serial.println("008-Issue client.stop");
client.stop();
Serial.println("009-Waiting for status = zero...");
while(client.status() != 0) delay(50);
Serial.println("010-Status went to zero");
Serial.println();
Serial.println();
}
else {
Serial.println("Connection failed");
Serial.print("Elapsed time(ms) = ");
Serial.println(millis()-time, DEC);
Serial.print(++failures, DEC);
Serial.println(" failures to connect since start");
Serial.println();
}
delay(1000);
}