Index: src/OFExceptions.h ================================================================== --- src/OFExceptions.h +++ src/OFExceptions.h @@ -326,10 +326,11 @@ * \brief An exception indicating a read or write to a stream failed. */ @interface OFReadOrWriteFailedException: OFException { size_t requestedSize; +@public int errNo; } #ifdef OF_HAVE_PROPERTIES @property (readonly) size_t requestedSize; Index: src/OFStreamSocket.m ================================================================== --- src/OFStreamSocket.m +++ src/OFStreamSocket.m @@ -66,17 +66,21 @@ ssize_t ret; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; -#ifndef _WIN32 - /* FIXME: We want a sane error message on Win32 as well */ - if (eos) - errno = ENOTCONN; -#endif + if (eos) { + OFReadFailedException *e; + + e = [OFReadFailedException newWithClass: isa + requestedSize: size]; + e->errNo = ENOTCONN; + + @throw e; + } - if (eos || (ret = recv(sock, buf, size, 0)) < 0) + if ((ret = recv(sock, buf, size, 0)) < 0) @throw [OFReadFailedException newWithClass: isa requestedSize: size]; if (ret == 0) eos = YES; @@ -90,17 +94,21 @@ ssize_t ret; if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; -#ifndef _WIN32 - /* FIXME: We want a sane error message on Win32 as well */ - if (eos) - errno = ENOTCONN; -#endif + if (eos) { + OFWriteFailedException *e; + + e = [OFWriteFailedException newWithClass: isa + requestedSize: size]; + e->errNo = ENOTCONN; + + @throw e; + } - if (eos || (ret = send(sock, buf, size, 0)) == -1) + if ((ret = send(sock, buf, size, 0)) == -1) @throw [OFWriteFailedException newWithClass: isa requestedSize: size]; /* This is safe, as we already checked for -1 */ return ret;