Skip to content

Commit 507d586

Browse files
committed
server: Initialize class member on dynamic alloc
I noticed that server worked on global instance. but not if used in class (allocated with new). This change makes both use working. Forwarded: stm32duino#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 507d586

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/EthernetServer.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ extern "C" {
66
#include "EthernetClient.h"
77
#include "EthernetServer.h"
88

9+
EthernetServer::EthernetServer()
10+
{
11+
_port = 80;
12+
_tcp_client[MAX_CLIENT] = {};
13+
_tcp_server = {};
14+
}
15+
916
EthernetServer::EthernetServer(uint16_t port)
1017
{
1118
_port = port;
19+
_tcp_client[MAX_CLIENT] = {};
20+
_tcp_server = {};
1221
}
1322

1423
void EthernetServer::begin()

src/EthernetServer.h

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

1515
void accept(void);
1616
public:
17-
EthernetServer(uint16_t);
17+
EthernetServer();
18+
EthernetServer(uint16_t port);
1819
EthernetClient available();
1920
virtual void begin();
2021
virtual size_t write(uint8_t);

0 commit comments

Comments
 (0)