From ea6a645dc8d5c99f73233338b7c2cb929ba6bc5f Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Fri, 8 May 2009 13:11:04 +0000 Subject: [PATCH] Fixing bugs in Client::connect() (failed to set _sock to 255 after some connection failures). --- hardware/libraries/Ethernet/Client.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hardware/libraries/Ethernet/Client.cpp b/hardware/libraries/Ethernet/Client.cpp index 13cf6bf54..ebbb08de4 100644 --- a/hardware/libraries/Ethernet/Client.cpp +++ b/hardware/libraries/Ethernet/Client.cpp @@ -42,13 +42,17 @@ uint8_t Client::connect() { if (_srcport + 1024 == 0) _srcport = 0; socket(_sock, Sn_MR_TCP, _srcport + 1024, 0); - if (!::connect(_sock, _ip, _port)) + if (!::connect(_sock, _ip, _port)) { + _sock = 255; return 0; + } while (status() != SOCK_ESTABLISHED) { delay(1); - if (status() == SOCK_CLOSED) + if (status() == SOCK_CLOSED) { + _sock = 255; return 0; + } } return 1;