Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ namespace websockets { namespace network {
WSString line = "";

int ch = -1;

const uint64_t millisBeforeReadingHeaders = millis();
while( ch != '\n' && available()) {
if (millis() - millisBeforeReadingHeaders > _CONNECTION_TIMEOUT) return "";
ch = client.read();
if (ch < 0) continue;
line += (char) ch;
Expand Down
3 changes: 3 additions & 0 deletions src/tiny_websockets/network/teensy41/teensy41_tcp_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@ namespace websockets { namespace network {
WSString line = "";

int ch = -1;

const uint64_t millisBeforeReadingHeaders = millis();
while( ch != '\n' && available()) {
// It is important to call `client.available()`. Otherwise no data can be read.
if (millis() - millisBeforeReadingHeaders > _CONNECTION_TIMEOUT) return "";
if (client.available()) {
ch = client.read();
if (ch >= 0) {
Expand Down
3 changes: 2 additions & 1 deletion src/tiny_websockets/ws_config_defs.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

#define _WS_CONFIG_NO_TRUE_RANDOMNESS
#define _WS_BUFFER_SIZE 512
#define _WS_BUFFER_SIZE 512
#define _CONNECTION_TIMEOUT 1000