Skip to content

Commit

Permalink
Merge branch 'master' into Arduino_1.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ntruchsess committed Mar 1, 2014
2 parents 8e838ca + 5155710 commit 75f473a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions UIPEthernet/src/UIPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ UIPClient::connect(IPAddress ip, uint16_t port)
struct uip_conn* conn = uip_connect(&ipaddr, htons(port));
if (conn)
{
#if UIP_CONNECT_TIMEOUT > 0
int32_t timeout = millis() + 1000 * UIP_CONNECT_TIMEOUT;
#endif
while((conn->tcpstateflags & UIP_TS_MASK) != UIP_CLOSED)
{
UIPEthernetClass::tick();
Expand All @@ -69,6 +72,13 @@ UIPClient::connect(IPAddress ip, uint16_t port)
#endif
return 1;
}
#if UIP_CONNECT_TIMEOUT > 0
if (((int32_t)(millis() - timeout)) > 0)
{
conn->tcpstateflags = UIP_CLOSED;
break;
}
#endif
}
}
return 0;
Expand Down
4 changes: 4 additions & 0 deletions UIPEthernet/src/utility/uipethernet-conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@
* set to -1 to block until connection is closed by timeout */
#define UIP_ATTEMPTS_ON_WRITE -1

/* timeout after which UIPClient::connect gives up. The timeout is specified in seconds.
* if set to a number <= 0 connect will timeout when uIP does (which might be longer than you expect...) */
#define UIP_CONNECT_TIMEOUT -1

#endif

0 comments on commit 75f473a

Please sign in to comment.