#include <EthernetClient.h>


Public Member Functions | |
| EthernetClient () | |
| Default constructor. Creates a client with no connection. | |
| EthernetClient (uint8_t sock) | |
| Deprecated constructor kept for W5100 sketch compatibility. | |
| EthernetClient (struct tcp_struct *tcpClient) | |
| Wraps an existing TCP connection. | |
| uint8_t | status () |
| Returns the state of the TCP connection. | |
| virtual int | connect (IPAddress ip, uint16_t port) |
| Connects to a remote host by IP address. | |
| virtual int | connect (const char *host, uint16_t port) |
| Connects to a remote host by host name. | |
| virtual size_t | write (uint8_t b) |
| Writes one byte to the connection. | |
| virtual size_t | write (const uint8_t *buf, size_t size) |
| Writes a buffer to the connection. | |
| virtual int | available () |
| Returns the number of bytes ready to be read. | |
| virtual int | read () |
| Reads one byte from the receive buffer. | |
| virtual int | read (uint8_t *buf, size_t size) |
| Reads up to size bytes from the receive buffer. | |
| virtual int | peek () |
| Returns the next byte without removing it from the buffer. | |
| virtual void | flush () |
| Sends any data still queued for transmission. | |
| virtual void | stop () |
| Closes the connection and releases the client structure. | |
| virtual uint8_t | connected () |
| Checks whether the client is connected. | |
| virtual | operator bool () |
| Tests whether the client holds a usable connection. | |
| virtual bool | operator== (const bool value) |
| Compares the client's boolean value with a value. | |
| virtual bool | operator!= (const bool value) |
| Compares the client's boolean value with a value. | |
| virtual bool | operator== (const EthernetClient &) |
| Tests whether two clients refer to the same connection. | |
| virtual bool | operator!= (const EthernetClient &rhs) |
| Tests whether two clients refer to different connections. | |
| uint8_t | getSocketNumber () |
| Returns the socket number, for W5100 compatibility. | |
| virtual uint16_t | localPort () |
| Returns the local TCP port of the connection. | |
| virtual IPAddress | remoteIP () |
| Returns the remote IP address of the connection. | |
| virtual uint16_t | remotePort () |
| Returns the remote TCP port of the connection. | |
| void | setConnectionTimeout (uint16_t timeout) |
| Sets how long connect() waits for the connection (ms). | |
Friends | |
| class | EthernetServer |
| EthernetClient::EthernetClient | ( | ) |
Default constructor. Creates a client with no connection.
| EthernetClient::EthernetClient | ( | uint8_t | sock | ) |
Deprecated constructor kept for W5100 sketch compatibility.
The socket argument is ignored and the client starts with no connection.
| sock | Socket number, ignored. |
| EthernetClient::EthernetClient | ( | struct tcp_struct * | tcpClient | ) |
Wraps an existing TCP connection.
The structure is used directly and is not copied. EthernetServer uses this constructor to return accepted clients.
| tcpClient | Pointer to the TCP connection structure to wrap. |
|
virtual |
Returns the number of bytes ready to be read.
Runs the network scheduler before checking the receive buffer.
|
virtual |
Connects to a remote host by host name.
Resolves the name with the DNS server configured in Ethernet, then connects to the resulting address.
| host | Host name to resolve. |
| port | Remote TCP port. |
|
virtual |
Connects to a remote host by IP address.
Blocks until the connection is established, fails, or the timeout set with setConnectionTimeout() expires.
| ip | Remote IP address. |
| port | Remote TCP port. |
|
virtual |
Checks whether the client is connected.
A client whose connection is closing still counts as connected while data remains to be read.
|
virtual |
Sends any data still queued for transmission.
Does not wait for the remote host to acknowledge the data.
| uint8_t EthernetClient::getSocketNumber | ( | ) |
Returns the socket number, for W5100 compatibility.
This function is specific to the W5100 architecture and is not defined by Arduino. It is kept for compatibility and always returns 0 because this implementation has no socket numbers.
|
inlinevirtual |
Returns the local TCP port of the connection.
Requires an active connection. No NULL check is performed.
|
virtual |
Tests whether the client holds a usable connection.
Lets the client returned by EthernetServer::available() be used as the condition of an if-statement.
|
inlinevirtual |
Compares the client's boolean value with a value.
| value | Value to compare with operator bool(). |
|
inlinevirtual |
Tests whether two clients refer to different connections.
| rhs | Client to compare with. |
|
inlinevirtual |
Compares the client's boolean value with a value.
| value | Value to compare with operator bool(). |
|
virtual |
Tests whether two clients refer to the same connection.
Two clients with no connection structure compare equal. A client with no connection never equals a client that has one.
| rhs | Client to compare with. |
|
virtual |
Returns the next byte without removing it from the buffer.
Runs the network scheduler through available().
|
virtual |
Reads one byte from the receive buffer.
|
virtual |
Reads up to size bytes from the receive buffer.
| buf | Destination buffer. |
| size | Maximum number of bytes to read. |
|
inlinevirtual |
Returns the remote IP address of the connection.
Requires an active connection. No NULL check is performed.
|
inlinevirtual |
Returns the remote TCP port of the connection.
Requires an active connection. No NULL check is performed.
|
inline |
Sets how long connect() waits for the connection (ms).
| timeout | Timeout in milliseconds. |
| uint8_t EthernetClient::status | ( | ) |
Returns the state of the TCP connection.
|
virtual |
Closes the connection and releases the client structure.
The connection is closed unless it is already in TCP_CLOSING state. The structure is freed only if this client allocated it in connect(). A structure shared with EthernetServer is left for the server to free, and the client is left with no connection.
|
virtual |
Writes a buffer to the connection.
Sends the data in chunks limited by the free space in the TCP send buffer, and forces each chunk out. Bytes queued before a TCP error are not reported.
| buf | Data to send. |
| size | Number of bytes in buf. |
|
virtual |
Writes one byte to the connection.
| b | Byte to send. |
|
friend |