Maybe I am misunderstanding something, but if I connect to a valid server:
#include <ESP8266WiFi.h>
WiFiClient client;
char* server = "adrianbowyer.com"; // My real domain that exists
.
.
.
if (client.connect(server, 80))
{
... Returns true, so I end up here as expected
}
But if I connect to an invalid server:
#include <ESP8266WiFi.h>
WiFiClient client;
char* server = "adrianbowyer.comx"; // Dud domain that doesn't exist; no DNS
.
.
.
if (client.connect(server, 80))
{
... Returns true, so I end up here. This is not what I would expect.
}
Assuming that the connect function is based on that in the ethernet library, it returns one for success and various negative numbers for different error conditions. All of those are non-zero, which, in the context of your if statement are therefore 'true'.
I see that the one on Github (GitHub - esp8266/Arduino: ESP8266 core for Arduino) is 2.5.0-dev (in the master branch), but I'm reluctant to use a dev version for something that will (I hope) go into production.