miscellaneous sloppa fixes

This commit is contained in:
shweet committed 2026-04-20 13:54:49 -04:00
1 parent bfe9e3e982
commit d39a1dac3c
11 files changed
+172 -109

No files matched your search

+9 -2
View File
@@ -1,6 +1,7 @@
#include "socket.hpp"
#include <cerrno>
#include <climits>
namespace anm2ed
{
@@ -203,7 +204,12 @@ namespace anm2ed
while (totalSent < size)
{
auto sent = ::send(handle, bytes + totalSent, static_cast<int>(size - totalSent), 0);
auto chunkSize = static_cast<int>(std::min<size_t>(size - totalSent, static_cast<size_t>(INT_MAX)));
#ifdef MSG_NOSIGNAL
auto sent = ::send(handle, bytes + totalSent, chunkSize, MSG_NOSIGNAL);
#else
auto sent = ::send(handle, bytes + totalSent, chunkSize, 0);
#endif
if (sent <= 0)
{
lastError = socket_last_error();
@@ -229,7 +235,8 @@ namespace anm2ed
while (totalReceived < size)
{
auto received = ::recv(handle, bytes + totalReceived, static_cast<int>(size - totalReceived), 0);
auto chunkSize = static_cast<int>(std::min<size_t>(size - totalReceived, static_cast<size_t>(INT_MAX)));
auto received = ::recv(handle, bytes + totalReceived, chunkSize, 0);
if (received <= 0)
{
lastError = socket_last_error();