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