Skip to content

Commit a443221

Browse files
committed
server: Initialize class member on dynamic alloc
Also replace default constructor to use port 80 by default. I noticed that server worked on global instance. but not if used in class (allocated with new). This change makes both use cases working. Forwarded: #17 Relate-to: https://github.com/rzr/webthing-iotjs/wiki/MCU Change-Id: I2e21e34a43f3cadb7981f2e359a5960735daa5d3 Signed-off-by: Philippe Coval <[email protected]>
1 parent be067d9 commit a443221

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/EthernetServer.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ extern "C" {
99
EthernetServer::EthernetServer(uint16_t port)
1010
{
1111
_port = port;
12+
_tcp_client[MAX_CLIENT] = {};
13+
_tcp_server = {};
1214
}
1315

1416
void EthernetServer::begin()

src/EthernetServer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public Server {
1414

1515
void accept(void);
1616
public:
17-
EthernetServer(uint16_t);
17+
EthernetServer(uint16_t port = 80);
1818
EthernetClient available();
1919
virtual void begin();
2020
virtual size_t write(uint8_t);

0 commit comments

Comments
 (0)