/** \file net.c networking-related helper functions */
-#include "error.h"
#include "para.h"
+#include "error.h"
#include "net.h"
#include "string.h"
total += n;
bytesleft -= n;
if (total < *len)
- PARA_DEBUG_LOG("short write (%zd byte(s) left)",
+ PARA_DEBUG_LOG("short write (%zd byte(s) left)\n",
*len - total);
}
*len = total; /* return number actually sent here */
* \param buf the buffer to write the decrypted data to
* \param size the size of \a buf
*
- * Receive at most \a size bytes from filedescriptor fd. If encryption is
+ * Receive at most \a size bytes from file descriptor \a fd. If encryption is
* available, decrypt the received buffer.
*
- * \return The number of bytes received on success. On receive errors, -E_RECV
- * is returned. On crypt errors, the corresponding crypt error number is
- * returned.
+ * \return The number of bytes received on success, negative on errors.
*
* \sa recv(2)
*/
} else
n = recv(fd, buf, size, 0);
if (n == -1)
- n = -E_RECV;
+ return -ERRNO_TO_PARA_ERROR(errno);
return n;
}
{
int n;
- if (!size)
- return -E_RECV;
+ assert(size);
n = recv_bin_buffer(fd, buf, size - 1);
if (n >= 0)
buf[n] = '\0';