Possible error in the Code of Reference page "ClientConnect"

Hi,

I hope this is the right place to post found mistakes in the documentation.

I stumbled upon the Reference for the "connect()" function of the class "Client" that can be found here.
My question concerns the example code on the page.
First of all the "[Get Code]" link does not work.
Secondly: Every non-zero integer is evaluated as true in c++ and connect() only returns non-zero characters. Therefore client.connect() will always return true when evaluated as a condition. This means the else part of the following code will never be reached:

if (client.connect(server, 80)) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }

I would suggest to change the code to

if (client.connect(server, 80) == 1) {
    Serial.println("connected");
    client.println("GET /search?q=arduino HTTP/1.0");
    client.println();
  } else {
    Serial.println("connection failed");
  }

It is not a big mistake, but it bothered me enough to create an account just to post this :smiley:

(deleted)

all Arduino networking libraries originate in the Ethernet library and there EthernetClient connect only returns 0 or 1 as true and false. The reference is wrong here

spycatcher2k:
The return can also be 0! Look at the source, the code only continues if a non zero is received.

I only found the source for the connect() of EthernetClient here. If that is the source you are referring to than it is clear that connect() only returns 0 or 1. But the Reference Page for client.connect() mentions different returns:

https://www.arduino.cc/en/Reference/ClientConnect:
Returns an int (1,-1,-2,-3,-4) indicating connection status :

  • SUCCESS 1
  • TIMED_OUT -1
  • INVALID_SERVER -2
  • TRUNCATED -3
  • INVALID_RESPONSE -4

So far the reference gives hope that it is possible to derive the reason for an unsuccessfull connect...

Juraj:
all Arduino networking libraries originate in the Ethernet library and there EthernetClient connect only returns 0 or 1 as true and false. The reference is wrong here

So who is responsible for fixing the reference?