Linux: Fix Ethernet client and server (#836)

- Fix documentation.
- Add function close() to client class.
- Function connected() now return true if the connection is in
  stablished state or there is still unread data.
- Update hasClient() to check if any client has disconnected.
- Fix _accept() to better handle the case of maximum clients reached.
- Fix peek() to return the next byte of the read queue.
- Simplifies write() of the server class.
- Implements flush().
- Updates read() to non-blocking type, the same way as in Arduino.
This commit is contained in:
Marcelo Aquino
2017-05-13 09:49:16 +02:00
committed by Henrik Ekblad
parent 95f719b604
commit a4c7b249c1
4 changed files with 83 additions and 77 deletions
+3 -3
View File
@@ -70,7 +70,7 @@ public:
/**
* @brief Get the new connected client.
*
* @return client class object if a new client has connected else -1.
* @return a EthernetClient object; if no new client has connected, this object will evaluate to false.
*/
EthernetClient available();
/**
@@ -106,8 +106,8 @@ public:
private:
uint16_t port; //!< @brief Port number for the network socket.
std::list<int> new_clients; //!< Socket list of new clients.
std::vector<int> clients; //!< @brief Socket list of clients.
std::list<int> new_clients; //!< Socket list of new connected clients.
std::vector<int> clients; //!< @brief Socket list of connected clients.
uint16_t max_clients; //!< @brief The maximum number of allowed clients.
int sockfd; //!< @brief Network socket used to accept connections.