if (!client.connect(server, port)) {
< print error message here>
}
<continue execution here>
Since WiFiClient is derived from "Client", I am assuming it's connect() method would return the same error codes as listed here: https://www.arduino.cc/en/Reference/ClientConnect
If this is the case, the if statement will be true only for the returned code "0", which doesn't even exist in the list. Any non-zero value (including the negative values) would be treated as as true and hence the not condition would fail for these, thinking the connection is successful. (AFAIK, this is the convention in C++).
Shouldn't the if statement be this instead:
if (client.connect(server, port) != 1){
<error ...>
}Am I wrong here?