REDAC HybridController
Firmware for LUCIDAC/REDAC Teensy
Loading...
Searching...
No Matches
ethernet_server.cpp
Go to the documentation of this file.
1#include <net/ethernet_server.h>
2
3namespace net {
4// Returns the server port. This will return -1 if it has not been set.
5//
6// Note that the value is still a 16-bit quantity if it is non-negative.
7int32_t EthernetServer::port() const { return hal_->port(); }
8
9// Starts listening on the server port, if set. This does not set the
10// SO_REUSEADDR socket option.
11//
12// This first calls end() if the _reuse_ socket option differs.
13void EthernetServer::begin() { hal_->begin(); }
14
15// Starts listening on the server port, if set, and sets the SO_REUSEADDR
16// socket option. This returns whether the server started listening. This will
17// always return false if the port is not set.
18//
19// This first calls end() if the _reuse_ socket option differs.
20bool EthernetServer::beginWithReuse() { return hal_->beginWithReuse(); }
21
22// Starts listening on the specified port. This does not set the SO_REUSEADDR
23// socket option. This returns whether the server started listening.
24//
25// This first calls end() if the port or _reuse_ socket option differ.
26bool EthernetServer::begin(uint16_t port) { return hal_->begin(port); }
27
28// Starts listening on the specified port, if set, and sets the SO_REUSEADDR
29// socket option. This returns whether the server started listening.
30//
31// If the port or _reuse_ socket option differ then this first calls end() to
32// prevent a single server object from representing more than one
33// listening socket.
34bool EthernetServer::beginWithReuse(uint16_t port) { return hal_->beginWithReuse(port); }
35
36// Stops listening. This does nothing if the port is not set or the server is
37// not listening.
38void EthernetServer::end() { return hal_->end(); };
39
40// Accepts a connection and returns a client, possibly unconnected. This
41// returns an unconnected client if the port is not set.
42EthernetClient EthernetServer::accept() const { return hal_->accept(); }
43
44// Finds a connection with available data. This returns an unconnected client
45// if there is no client with available data or if the port is not set.
46EthernetClient EthernetServer::available() const { return hal_->available(); }
47
48// Writes a byte to all the connections. This does nothing and returns 1 if
49// the port is not set.
50size_t EthernetServer::write(uint8_t b) { return hal_->write(b); }
51
52// Writes data to all the connections. This does nothing and returns size if
53// the port is not set.
54size_t EthernetServer::write(const uint8_t *buffer, size_t size) { return hal_->write(buffer, size); }
55
56// Returns the minimum availability of all the connections, or zero if there
57// are no connections or if the port is not set.
58int EthernetServer::availableForWrite() { return hal_->availableForWrite(); }
59
60// Flushes all the connections, but does nothing is the port is not set.
61void EthernetServer::flush() { hal_->flush(); }
62
63EthernetServer::operator bool() const { return hal_->operator bool(); }
64
65} // namespace net