Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PicoTCP by
Diff: Socket/TCPSocketConnection.cpp
- Revision:
- 24:8bff2b51ea3b
- Parent:
- 19:c7debad9a20a
--- a/Socket/TCPSocketConnection.cpp Mon Jun 10 08:01:01 2013 +0000
+++ b/Socket/TCPSocketConnection.cpp Tue Jun 11 21:10:23 2013 +0000
@@ -64,6 +64,7 @@
}
int TCPSocketConnection::send(char* data, int length) {
+ int ret;
if ((_ep < 0) || !_is_connected)
return -1;
@@ -75,11 +76,17 @@
return -1;
}
}
- return picotcp_write(_ep, data, length);
+ ret = picotcp_write(_ep, data, length);
+ if (ret < length) {
+ _ep->revents &= (~PICO_SOCK_EV_WR);
+ printf("Short write\n");
+ }
+ return ret;
}
// -1 if unsuccessful, else number of bytes written
int TCPSocketConnection::send_all(char* data, int length) {
+ int ret;
if ((_ep < 0) || !_is_connected)
return -1;
@@ -90,10 +97,16 @@
return 0;
}
}
- return picotcp_write(_ep, data, length);
+ ret = picotcp_write(_ep, data, length);
+ if (ret < length) {
+ _ep->revents &= (~PICO_SOCK_EV_WR);
+ //printf("Short write\n");
+ }
+ return ret;
}
int TCPSocketConnection::receive(char* data, int length) {
+ int ret;
if ((_ep < 0) || !_is_connected)
return -1;
@@ -105,7 +118,12 @@
return -1;
}
}
- return picotcp_read(_ep, data, length);
+ ret = picotcp_read(_ep, data, length);
+ if (ret < length) {
+ _ep->revents &= (~PICO_SOCK_EV_RD);
+ //printf("Short read\n");
+ }
+ return ret;
}
// -1 if unsuccessful, else number of bytes received
