mirror of
https://github.com/arduino/Arduino.git
synced 2025-03-14 11:29:26 +01:00
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.
This commit is contained in:
parent
66eb0852f7
commit
983d8af814
@ -77,7 +77,7 @@ int Client::available() {
|
|||||||
|
|
||||||
int Client::read() {
|
int Client::read() {
|
||||||
uint8_t b;
|
uint8_t b;
|
||||||
if ( recv(_sock, &b, 1) )
|
if ( recv(_sock, &b, 1) > 0 )
|
||||||
{
|
{
|
||||||
// recv worked
|
// recv worked
|
||||||
return b;
|
return b;
|
||||||
|
@ -148,7 +148,22 @@ uint16_t recv(SOCKET s, uint8_t *buf, uint16_t len)
|
|||||||
{
|
{
|
||||||
// Check how much data is available
|
// Check how much data is available
|
||||||
uint16_t ret = W5100.getRXReceivedSize(s);
|
uint16_t ret = W5100.getRXReceivedSize(s);
|
||||||
if (ret > len)
|
if ( ret == 0 )
|
||||||
|
{
|
||||||
|
// No data available.
|
||||||
|
uint8_t status = W5100.readSnSR(s);
|
||||||
|
if ( s == SnSR::LISTEN || s == SnSR::CLOSED || s == SnSR::CLOSE_WAIT )
|
||||||
|
{
|
||||||
|
// The remote end has closed its side of the connection, so this is the eof state
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The connection is still up, but there's no data waiting to be read
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (ret > len)
|
||||||
{
|
{
|
||||||
ret = len;
|
ret = len;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user