|
33 | 33 | class WiFiClient : public Client {
|
34 | 34 |
|
35 | 35 | public:
|
| 36 | + /** |
| 37 | + * @brief Default constructor for the WiFiClient class. |
| 38 | + */ |
36 | 39 | WiFiClient();
|
| 40 | + |
37 | 41 | /* this constructor is not intended to be called outside of the Server class */
|
| 42 | + /** |
| 43 | + * @brief Constructor to initialize a WiFiClient object with a specific socket. |
| 44 | + * |
| 45 | + * @param `s` is the socket descriptor to associate with this client. |
| 46 | + */ |
38 | 47 | WiFiClient(int s);
|
| 48 | + |
| 49 | + /** |
| 50 | + * @brief Copy constructor for the WiFiClient class. |
| 51 | + * |
| 52 | + * @param `c` is the `WiFiClient` object to copy. |
| 53 | + */ |
39 | 54 | WiFiClient(const WiFiClient& c);
|
40 | 55 | ~WiFiClient();
|
41 | 56 |
|
| 57 | + |
42 | 58 | /**
|
43 |
| - * @brief Establish a connection to a remote server using the specified IP address and port number. |
| 59 | + * @brief Establishes a connection to a server using an IP address and port. |
| 60 | + * |
| 61 | + * This function initiates a connection to a server using the specified IP address |
| 62 | + * and port. Internally, it converts the IP address to a string and delegates |
| 63 | + * the connection task to the `connect(const char*, uint16_t)` method. |
| 64 | + * |
| 65 | + * @param ip The IP address of the server to connect to. |
| 66 | + * @param port The port number on the server to connect to. |
| 67 | + * |
| 68 | + * @return `1` on a successful connection, `0` on failure. |
| 69 | + */ |
| 70 | + |
| 71 | + /** |
| 72 | + * @brief Establishes a connection to a server using an IP address and port. |
| 73 | + * |
| 74 | + * @param Using `ip` as the IP address of the server to connect to. |
| 75 | + * And `port` as the port number on the server to connect to. |
| 76 | + * |
| 77 | + * @return `1` on a successful connection, `0` on failure. |
44 | 78 | */
|
45 | 79 | virtual int connect(IPAddress ip, uint16_t port);
|
46 | 80 |
|
47 | 81 | /**
|
48 |
| - * @brief Establish a connection to a remote server. |
| 82 | + * @brief Establishes a connection to a server using a hostname and port. |
49 | 83 | *
|
50 |
| - * @param Uses the specified domain name or IP address `host` and `port` for port number. |
| 84 | + * @param `host` is a pointer to a null-terminated string containing the hostname of the server. |
| 85 | + * And `port` is the port number on the server to connect to. |
| 86 | + * |
| 87 | + * @return `1` if the connection was successful, `0` otherwise. |
51 | 88 | */
|
52 | 89 | virtual int connect(const char *host, uint16_t port);
|
53 |
| - |
| 90 | + |
54 | 91 | /**
|
55 |
| - * @brief Writes a single byte of data to the connected client. |
| 92 | + * @brief Sends a single byte of data to the connected server. |
| 93 | + * |
| 94 | + * @param `b` being the byte of data to send. |
| 95 | + * |
| 96 | + * @return The number of bytes successfully written, which is `1` on success or `0` on failure. |
56 | 97 | */
|
57 | 98 | virtual size_t write(uint8_t);
|
58 | 99 |
|
59 | 100 | /**
|
60 |
| - * @brief Writes a buffer of data to the connected client. |
| 101 | + * @brief Writes a buffer of data to the connected server. |
61 | 102 | *
|
62 | 103 | * @param Takes a pointer to a buffer `buf` containing the data to be written
|
63 | 104 | * and the size of the buffer `size` as parameters.
|
64 | 105 | *
|
65 |
| - * @return The function writes the data in the buffer to the connected client |
66 |
| - * and returns the number of bytes written. |
| 106 | + * @return The number of bytes successfully written, or `0` if the write operation fails. |
67 | 107 | */
|
68 | 108 | virtual size_t write(const uint8_t *buf, size_t size);
|
69 | 109 |
|
70 | 110 | /**
|
71 |
| - * @brief Checks how many bytes are available for reading from the connected client. |
| 111 | + * @brief Checks the number of bytes available for reading from the server. |
| 112 | + * |
| 113 | + * @return The number of bytes available to read. Returns `0` if no data is |
| 114 | + * available, or if the socket is invalid. |
72 | 115 | */
|
73 | 116 | virtual int available();
|
74 | 117 |
|
75 | 118 | /**
|
76 |
| - * @brief Reads a single byte of data from the connected client. |
| 119 | + * @brief Reads a single byte of data from the server. |
| 120 | + * |
| 121 | + * @return The byte read as an `int` (0–255). Returns `-1` if no data is available |
| 122 | + * or if an error occurs. |
77 | 123 | */
|
78 | 124 | virtual int read();
|
79 | 125 |
|
80 | 126 | /**
|
81 |
| - * @brief Reads a specified number of bytes from the connected client into a buffer. |
| 127 | + * @brief Reads multiple bytes of data from the server into a buffer. |
| 128 | + * |
| 129 | + * This function retrieves data from the server's receive buffer and stores it |
| 130 | + * into the provided array. It attempts to read up to the specified number of |
| 131 | + * bytes (`size`). The function stops reading if no more data is available or |
| 132 | + * if an error occurs. |
| 133 | + * |
| 134 | + * @param[out] buf Pointer to the buffer where the data will be stored. |
| 135 | + * @param[in] size Maximum number of bytes to read. |
| 136 | + * @return The number of bytes successfully read into the buffer. |
| 137 | + * Returns `0` if no data is available or if the socket is invalid. |
| 138 | + */ |
| 139 | + |
| 140 | + /** |
| 141 | + * @brief Reads multiple bytes of data from the server into a buffer. |
| 142 | + * |
| 143 | + * This function retrieves data from the server's receive buffer and stores it |
| 144 | + * into the provided array. It attempts to read up to the specified number of |
| 145 | + * bytes (`size`). |
| 146 | + * |
| 147 | + * @param[out] `buf` is a pointer to the buffer where the data will be stored. |
| 148 | + * @param[in] `size` is the maximum number of bytes to read. |
| 149 | + * |
| 150 | + * @return The number of bytes successfully read into the buffer. |
| 151 | + * Returns `0` if no data is available or if the socket is invalid. |
82 | 152 | */
|
83 | 153 | virtual int read(uint8_t *buf, size_t size);
|
84 | 154 |
|
|
0 commit comments