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