I am using a due and an ethernet shield to connect to an SMTP server and send email. My program makes the connection quite easily and sends email when a valid domain name is entered. When an invalid domain name is entered such as "mail.inbox.com" it halts and eventually trips the watchdog.
It's hundreds of lines of code long but the part that hangs up is:
EthernetClient SMTP;
if (SMTP.connect("mail.inbox.com", 25)) {
Serial.println("Connected");
// code to send email
return true;
}
else{
Serial.println("failed to connect")
return false;
}
I have a working DNS configured and like I said it works with a valid smpt server domain name. I guess I am wondering if there is any way to modify this of some library to time out when it cant make a connection.
Cheers
I guess I am wondering if there is any way to modify this of some library to time out when it cant make a connection.
Modify "this" what? The EthernetClient::connect() method DOES time out if a connection can not be made. It may not time out soon enough for you. In which case, I advise not hard-coding a bad domain name. 8)
I guess I am wondering if there is any way to modify this of some library to time out when it cant make a connection.
Modify "this" what? The EthernetClient::connect() method DOES time out if a connection can not be made. It may not time out soon enough for you. In which case, I advise not hard-coding a bad domain name. 8)
The domain name string is passed to this function and it's entered through a web interface among other variables...Therefor I can't control what is fed to it. This example is hard coded yes but this was my trial subroutine. Is there a way to modify the time out for connect()? its clearly greater then the watchdog if it's causing this..
Is there a way to modify the time out for connect()?
The code for the connect method that actually gets used:
int EthernetClient::connect(IPAddress ip, uint16_t port) {
if (_sock != MAX_SOCK_NUM)
return 0;
for (int i = 0; i < MAX_SOCK_NUM; i++) {
uint8_t s = W5100.readSnSR(i);
if (s == SnSR::CLOSED || s == SnSR::FIN_WAIT || s == SnSR::CLOSE_WAIT) {
_sock = i;
break;
}
}