summaryrefslogtreecommitdiff
path: root/extra/yassl/src/socket_wrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'extra/yassl/src/socket_wrapper.cpp')
-rw-r--r--extra/yassl/src/socket_wrapper.cpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/extra/yassl/src/socket_wrapper.cpp b/extra/yassl/src/socket_wrapper.cpp
index 3cf6c14c4b3..d88df13c08e 100644
--- a/extra/yassl/src/socket_wrapper.cpp
+++ b/extra/yassl/src/socket_wrapper.cpp
@@ -109,19 +109,28 @@ uint Socket::get_ready() const
}
-uint Socket::send(const byte* buf, unsigned int sz, int flags) const
+uint Socket::send(const byte* buf, unsigned int sz, unsigned int& written,
+ int flags)
{
const byte* pos = buf;
const byte* end = pos + sz;
+ wouldBlock_ = false;
+
while (pos != end) {
int sent = ::send(socket_, reinterpret_cast<const char *>(pos),
static_cast<int>(end - pos), flags);
-
- if (sent == -1)
- return 0;
-
+ if (sent == -1) {
+ if (get_lastError() == SOCKET_EWOULDBLOCK ||
+ get_lastError() == SOCKET_EAGAIN) {
+ wouldBlock_ = true; // would have blocked this time only
+ nonBlocking_ = true; // nonblocking, win32 only way to tell
+ return 0;
+ }
+ return static_cast<uint>(-1);
+ }
pos += sent;
+ written += sent;
}
return sz;
@@ -140,8 +149,8 @@ uint Socket::receive(byte* buf, unsigned int sz, int flags)
get_lastError() == SOCKET_EAGAIN) {
wouldBlock_ = true; // would have blocked this time only
nonBlocking_ = true; // socket nonblocking, win32 only way to tell
- return 0;
- }
+ return 0;
+ }
}
else if (recvd == 0)
return static_cast<uint>(-1);