Claude aa4be1e203 Fix socket error handling: WSASetLastError on Windows and recv() return value
Corrected two critical issues with socket mock precision:

**1. Windows Socket Error Handling:**
- Socket functions on Windows use WSAGetLastError/WSASetLastError, NOT errno
- Added SET_SOCKET_ERROR macro that calls:
  - WSASetLastError() on Windows
  - errno assignment on Linux
- Mapped all POSIX error codes to WSA equivalents:
  - EWOULDBLOCK → WSAEWOULDBLOCK
  - EAFNOSUPPORT → WSAEAFNOSUPPORT
  - EMFILE → WSAEMFILE
  - EBADF → WSAEBADF
  - ENOTSOCK → WSAENOTSOCK
  - EINVAL → WSAEINVAL
  - EADDRINUSE → WSAEADDRINUSE
  - EDESTADDRREQ → WSAEDESTADDRREQ
  - ECONNABORTED → WSAECONNABORTED
  - EISCONN → WSAEISCONN
  - EINPROGRESS → WSAEINPROGRESS
  - EOPNOTSUPP → WSAEOPNOTSUPP
  - ENOTCONN → WSAENOTCONN
  - ECONNRESET → WSAECONNRESET
  - ENOPROTOOPT → WSAENOPROTOOPT
  - EPIPE → WSAESHUTDOWN (Windows equivalent)

**2. Fixed mock_recv() Return Value:**
- Now returns 0 when peer closes connection (orderly shutdown)
- Previously returned -1 with ECONNRESET
- This matches standard POSIX/Winsock behavior:
  - 0 = peer closed connection gracefully
  - -1 = error occurred (check errno/WSAGetLastError)
  - >0 = bytes received

**Updated Functions:**
- mock_socket, mock_bind, mock_listen, mock_accept
- mock_connect, mock_recv, mock_send
- mock_getsockopt, mock_setsockopt

All socket functions now use correct error reporting mechanism
for their platform, improving simulation accuracy.
2025-11-02 10:33:44 +00:00
2025-10-29 10:41:23 +01:00
2025-11-01 22:44:04 +01:00
2025-10-27 18:01:33 +01:00
2025-10-29 10:41:23 +01:00
2025-10-28 17:24:25 +01:00
S
Description
A simple, fault-tolerant, highly available object storage
MIT
1.1 MiB
Languages
C 98.4%
Shell 1%
Zig 0.4%
Batchfile 0.2%