Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/bsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,17 @@ LIBUS_SOCKET_DESCRIPTOR bsd_create_socket(int domain, int type, int protocol) {
}

void bsd_close_socket(LIBUS_SOCKET_DESCRIPTOR fd) {
// errno is rewritten by close(fd), and the actual error number is lost.
#ifdef _WIN32
DWORD error;
error = GetLastError();
closesocket(fd);
SetLastError(error);
#else
int error;
error = errno;
close(fd);
errno = error;
#endif
}

Expand Down