Skip to content

Commit

Permalink
Merge pull request #74 from fpistm/setConnectionTimeout
Browse files Browse the repository at this point in the history
fix(client): setTimeout shadows Stream.setTimeout
  • Loading branch information
fpistm authored Sep 29, 2023
2 parents aa55112 + 6d46fb0 commit 60bbf39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
13 changes: 11 additions & 2 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@ peek KEYWORD2
flush KEYWORD2
stop KEYWORD2
connected KEYWORD2
accept KEYWORD2
begin KEYWORD2
beginMulticast KEYWORD2
beginPacket KEYWORD2
endPacket KEYWORD2
parsePacket KEYWORD2
remoteIP KEYWORD2
remotePort KEYWORD2
getSocketNumber KEYWORD2
localIP KEYWORD2
MACAddress KEYWORD2
localPort KEYWORD2
maintain KEYWORD2
linkStatus KEYWORD2
MACAddress KEYWORD2
subnetMask KEYWORD2
gatewayIP KEYWORD2
dnsServerIP KEYWORD2
setConnectionTimeout KEYWORD2

#######################################
# Constants (LITERAL1)
#######################################

LinkON LITERAL1
LinkOFF LITERAL1
2 changes: 1 addition & 1 deletion src/EthernetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int EthernetClient::connect(IPAddress ip, uint16_t port)
startTime = millis();
while (_tcp_client->state == TCP_NONE) {
stm32_eth_scheduler();
if ((_tcp_client->state == TCP_CLOSING) || ((millis() - startTime) >= _timeout)) {
if ((_tcp_client->state == TCP_CLOSING) || ((millis() - startTime) >= _connectionTimeout)) {
stop();
return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/EthernetClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class EthernetClient : public Client {
{
return (_tcp_client->pcb->remote_port);
};
void setTimeout(uint16_t timeout)
void setConnectionTimeout(uint16_t timeout)
{
_timeout = timeout;
_connectionTimeout = timeout;
}

friend class EthernetServer;
Expand All @@ -63,7 +63,7 @@ class EthernetClient : public Client {

private:
struct tcp_struct *_tcp_client;
uint16_t _timeout = 10000;
uint16_t _connectionTimeout = 10000;
};

#endif

0 comments on commit 60bbf39

Please sign in to comment.