Skip to content

Commit 2e3bee7

Browse files
committed
2 parents 7c90128 + 586664b commit 2e3bee7

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

ArduinoCore-Linux/cores/arduino/Ethernet.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ArduinoLogger.h"
2727
#include "RingBufferExt.h"
2828
#include "SocketImpl.h"
29+
#include "SignalHandler.h"
2930
#include "api/Client.h"
3031
#include "api/Common.h"
3132
#include "api/IPAddress.h"
@@ -81,14 +82,16 @@ class EthernetClient : public Client {
8182
active_clients().push_back(this);
8283
}
8384
EthernetClient(SocketImpl* sock, int bufferSize = 256, long timeout = 2000) {
84-
setTimeout(timeout);
85-
this->bufferSize = bufferSize;
86-
readBuffer = RingBufferExt(bufferSize);
87-
writeBuffer = RingBufferExt(bufferSize);
88-
p_sock = sock;
89-
is_connected = p_sock->connected();
90-
registerCleanup();
91-
active_clients().push_back(this);
85+
if (sock) {
86+
setTimeout(timeout);
87+
this->bufferSize = bufferSize;
88+
readBuffer = RingBufferExt(bufferSize);
89+
writeBuffer = RingBufferExt(bufferSize);
90+
p_sock = sock;
91+
is_connected = p_sock->connected();
92+
registerCleanup();
93+
active_clients().push_back(this);
94+
}
9295
}
9396
EthernetClient(int socket) {
9497
setTimeout(2000);

ArduinoCore-Linux/cores/arduino/EthernetServer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ class EthernetServer : public Server {
172172
// non blocking check if we have any request to accept
173173
if (!is_blocking) {
174174
if (poll_rc <= 0 || !(pfd.revents & POLLIN)) {
175-
EthernetClient result;
175+
EthernetClient result(nullptr);
176176
return result;
177177
}
178178
}
179179

180180
// accept client connection (blocking call)
181181
if ((client_fd = ::accept(server_fd, (struct sockaddr*)&client_addr,
182182
&client_addr_len)) < 0) {
183-
EthernetClient result;
183+
EthernetClient result(nullptr);
184184
Logger.error("accept failed");
185185
return result;
186186
}

ArduinoCore-Linux/cores/arduino/SignalHandler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <map>
2626
#include <algorithm>
2727

28+
#undef INADDR_NONE
29+
2830
// Generic signal handler utility
2931
class SignalHandler {
3032
public:

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ option(USE_HTTPS "Https Support" OFF)
99
option(USE_RPI "Raspberry Pi Support" OFF)
1010
option(USE_REMOTE "Remote API Support" OFF)
1111
option(BUILD_SHARED_LIBS "Build with shared libraries" ON)
12+
option(BUILD_EXAMPLES "Build with examples" OFF)
1213

1314
# Https support: Build with wolfssl
1415
if(USE_HTTPS)
@@ -94,4 +95,6 @@ if(USE_FTDI)
9495
endif(USE_FTDI)
9596

9697
# build examples
97-
add_subdirectory("examples")
98+
if(BUILD_EXAMPLES)
99+
add_subdirectory("examples")
100+
endif(BUILD_EXAMPLES)

0 commit comments

Comments
 (0)