REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
ethernet_client.cpp
Go to the documentation of this file.
1
2#include <net/ethernet_client.h>
3
4namespace net {
5
6FLASHMEM int EthernetClient::connect(IPAddress ip, uint16_t port) { return hal_->connect(ip, port); }
7
8// Returns INVALID_SERVER (-2) if DNS is disabled.
9FLASHMEM int EthernetClient::connect(const char *host, uint16_t port) { return hal_->connect(host, port); }
10
11// These functions start the connection process but don't wait for the
12// connection to be complete. Note that DNS lookup might still take some time.
13// Neither of these will return TIMED_OUT (-1).
14FLASHMEM int EthernetClient::connectNoWait(const IPAddress &ip, uint16_t port) {
15 return hal_->connectNoWait(ip, port);
16}
17
18// Returns INVALID_SERVER (-2) if DNS is disabled.
19FLASHMEM int EthernetClient::connectNoWait(const char *host, uint16_t port) {
20 return hal_->connectNoWait(host, port);
21}
22
23FLASHMEM uint8_t EthernetClient::connected() { return hal_->connected(); }
24
25FLASHMEM EthernetClient::operator bool() { return hal_->operator bool(); }
26
27FLASHMEM void EthernetClient::setConnectionTimeout(uint16_t timeout) {
28 return hal_->setConnectionTimeout(timeout);
29}
30
31// Returns the current timeout value.
32FLASHMEM uint16_t EthernetClient::connectionTimeout() const { return hal_->connectionTimeout(); }
33
34FLASHMEM void EthernetClient::stop() { return hal_->stop(); }
35
36// Closes the connection. This works the same as stop(), but without waiting
37// for the connection to close.
38FLASHMEM void EthernetClient::close() { return hal_->close(); }
39
40// Closes the sending side of this connection.
41FLASHMEM void EthernetClient::closeOutput() { return hal_->closeOutput(); }
42
43// Kills the connection without going through the TCP close process.
44FLASHMEM void EthernetClient::abort() { return hal_->abort(); }
45
46FLASHMEM uint16_t EthernetClient::localPort() { return hal_->localPort(); }
47
48FLASHMEM IPAddress EthernetClient::remoteIP() { return hal_->remoteIP(); }
49
50FLASHMEM uint16_t EthernetClient::remotePort() { return hal_->remotePort(); }
51
52// Returns the local IP address for this connection, or INADDR_NONE if this
53// client is not connected.
54FLASHMEM IPAddress EthernetClient::localIP() { return hal_->localIP(); }
55
56// Returns an ID for the connection to which this client refers. It will
57// return non-zero if connected and zero if not connected.
58//
59// This is useful because of the way EthernetClient objects can be passed
60// around, copied, and moved, etc. Just taking an address of the object won't
61// work because more than one object could refer to the same connection.
62//
63// Note that while multiple active connections won't share the same ID, it's
64// possible for new connections to reuse IDs that aren't currently in use. In
65// other words, there is a one-to-one correspondence between the set of
66// connection IDs and currently active connections.
67FLASHMEM uintptr_t EthernetClient::connectionId() { return hal_->connectionId(); }
68
69// Functions that loop until all bytes are written. If the connection is
70// closed before all bytes are sent then these break early and return the
71// actual number of bytes sent. In other words, these only return a value less
72// than the specified size if the connection was closed.
73FLASHMEM size_t EthernetClient::writeFully(uint8_t b) { return hal_->writeFully(b); }
74
75FLASHMEM size_t EthernetClient::writeFully(const char *s) { return hal_->writeFully(s); }
76
77FLASHMEM size_t EthernetClient::writeFully(const char *s, size_t size) { return hal_->writeFully(s, size); }
78
79FLASHMEM size_t EthernetClient::writeFully(const uint8_t *buf, size_t size) {
80 return hal_->writeFully(buf, size);
81}
82
83FLASHMEM size_t EthernetClient::write(uint8_t b) { return hal_->write(b); }
84
85FLASHMEM size_t EthernetClient::write(const uint8_t *buf, size_t size) { return hal_->write(buf, size); }
86
87FLASHMEM int EthernetClient::availableForWrite() { return hal_->availableForWrite(); }
88
89FLASHMEM void EthernetClient::flush() { return hal_->flush(); }
90
91FLASHMEM int EthernetClient::available() { return hal_->available(); }
92
93FLASHMEM int EthernetClient::read() { return hal_->read(); }
94
95// A NULL buffer allows the caller to skip bytes without having to read into
96// a buffer.
97FLASHMEM int EthernetClient::read(uint8_t *buf, size_t size) { return hal_->read(); }
98
99FLASHMEM int EthernetClient::peek() { return hal_->peek(); }
100
101// ----------------
102// Socket Options
103// ----------------
104
105// Disables or enables Nagle's algorithm. This sets or clears the TCP_NODELAY
106// flag. If the flag is set then Nagle's algorithm is disabled, otherwise it
107// is enabled. Note that this option must be set for each new connection.
108FLASHMEM void EthernetClient::setNoDelay(bool flag) { return hal_->setNoDelay(flag); }
109
110// Returns the value of the TCP_NODELAY flag for the current connection. This
111// returns false if not connected.
112FLASHMEM bool EthernetClient::isNoDelay() { return hal_->isNoDelay(); }
113
114} // namespace net
uint32_t uint32_t size
Definition flasher.cpp:63