Closed adyn closed 10 years ago
The regular (blocking) connect() will wait until the tcp-timeouts have expired (which is several minutes...) before it recovers. If the initial SYN-packet happens to never reach the remote-host plugging back might not help immediatly in this case as the retransmits will take more and more time. I have no plans to change that. But you may want to check out the nonblocking connect() that is to be found in the 'ext-branch' https://github.com/ntruchsess/arduino_uip/tree/ext/examples/NonBlockingTcpClient
I added the option to configure a connect-timeout that is independent of uIP internal timeouts: https://github.com/ntruchsess/arduino_uip/commit/5155710ea05a8c542d7588c9f01c1351334df5fd
configure by setting UIP_CONNECT_TIMEOUT in https://github.com/ntruchsess/arduino_uip/blob/master/utility/uipethernet-conf.h#L19.
closing this as fixed. If the change doesn't suit your needs or you run into further issues reopen or create a new issue - whatever is more appropriate.
Great library but unfortunately I hit some issues.
One of them (the easiest to reproduce) is this:
I have a client that sens http requests every few seconds to a server. If I remove the ethernet cable the program won't return from client.connect() function (even after I plug it back in). Here it is the sketch I use (with an Arduino Nano).
--------------------------------------------- Sketch
include <UIPEthernet.h>
EthernetClient client;
int cntSuccess = 0; int cntFailure = 0; int retry = 0; uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
void setup() {
Serial.begin(9600); Serial.println("Start..."); resetEthernet(); }
void resetEthernet() { Ethernet.begin(mac);
Serial.print("localIP: "); Serial.println(Ethernet.localIP()); Serial.print("subnetMask: "); Serial.println(Ethernet.subnetMask()); Serial.print("gatewayIP: "); Serial.println(Ethernet.gatewayIP()); Serial.print("dnsServerIP: "); Serial.println(Ethernet.dnsServerIP()); }
void loop() {
// --- SEND REQUEST ------------------------------------------------------------------------------ if (client.connect(IPAddress(157,166,226,26), 80)) { Serial.print("connected "); Serial.println(cntSuccess++);
} else { Serial.print("connection failed "); Serial.println(cntFailure++); retry ++; if(retry == 3) { resetEthernet(); retry = 0; } delay(1000); } }
---------------------- Output Start... localIP: 192.168.1.118 subnetMask: 255.255.255.0 gatewayIP: 192.168.1.1 dnsServerIP: 208.122.23.22 connected 0 connected 1 connected 2
At this point I removed the cable and I plugged it back after a few seconds and nothing happened forward.