Date: Friday, March 3, 2006 @ 16:01:13
Author: marc
Path: /cvsroot/carob/carob/src
Modified: JavaSocket.cpp (1.44 -> 1.45)
Trying to make recvFully() and ::receiveFromSocket() clearer (CAROB-66)
----------------+
JavaSocket.cpp | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
Index: carob/src/JavaSocket.cpp
diff -u carob/src/JavaSocket.cpp:1.44 carob/src/JavaSocket.cpp:1.45
--- carob/src/JavaSocket.cpp:1.44 Thu Mar 2 13:59:44 2006
+++ carob/src/JavaSocket.cpp Fri Mar 3 16:01:13 2006
@@ -328,6 +328,7 @@
sendToSocket(fctName, L"JavaBytes", data, length, SOCKET_SEND_FLAGS);
}
+/** Returns the number of octets read or the (negative) error from recv() */
int JavaSocket::recvFully(void *buf, const int len, const int flags)
const
{
@@ -347,7 +348,7 @@
}
alreadyRead += readThisTime;
}
- return len;
+ return alreadyRead;
}
void JavaSocket::sendToSocket(const wstring& fctName, const wstring& objName,
@@ -375,15 +376,20 @@
const wstring& objName, void *buf, int len, int flags) const
throw (SocketIOException, UnexpectedException)
{
+ if (0 == len)
+ return;
+
int status = recvFully(buf, len, flags);
+
if (status == -1)
- {
throw SocketIOException(fctName + L"Could not read from socket.");
- }
- else if (status == 0 && len > 0)
- {
- throw SocketIOException(fctName + L"Peer reset connection while reading
integer.");
- }
+
+ if (status == 0)
+ throw SocketIOException(fctName + L"Peer reset connection while
receiving");
+
+ // else it went fine
+ // if (status != len)
+ // throw SocketIOException(fctName + L"something is really wrong!");
}
const uint64_t JavaSocket::ntohll(const uint64_t &n) const
_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits