Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 983d8af

Browse filesBrowse files
committed
Final changes for the Client part of issue 416, which actually include the corrent return values. This should have been in the previous commit, but I'm still getting my head round git.
1 parent 66eb085 commit 983d8af
Copy full SHA for 983d8af

File tree

Expand file treeCollapse file tree

2 files changed

+17
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+17
-2
lines changed

‎libraries/Ethernet/Client.cpp

Copy file name to clipboardExpand all lines: libraries/Ethernet/Client.cpp
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ int Client::available() {
7777

7878
int Client::read() {
7979
uint8_t b;
80-
if ( recv(_sock, &b, 1) )
80+
if ( recv(_sock, &b, 1) > 0 )
8181
{
8282
// recv worked
8383
return b;

‎libraries/Ethernet/utility/socket.cpp

Copy file name to clipboardExpand all lines: libraries/Ethernet/utility/socket.cpp
+16-1Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,22 @@ uint16_t recv(SOCKET s, uint8_t *buf, uint16_t len)
148148
{
149149
// Check how much data is available
150150
uint16_t ret = W5100.getRXReceivedSize(s);
151-
if (ret > len)
151+
if ( ret == 0 )
152+
{
153+
// No data available.
154+
uint8_t status = W5100.readSnSR(s);
155+
if ( s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::CLOSE_WAIT )
156+
{
157+
// The remote end has closed its side of the connection, so this is the eof state
158+
ret = 0;
159+
}
160+
else
161+
{
162+
// The connection is still up, but there's no data waiting to be read
163+
ret = -1;
164+
}
165+
}
166+
else if (ret > len)
152167
{
153168
ret = len;
154169
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.