summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/close.c
diff options
context:
space:
mode:
Diffstat (limited to 'otherlibs/win32unix/close.c')
-rw-r--r--otherlibs/win32unix/close.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/otherlibs/win32unix/close.c b/otherlibs/win32unix/close.c
index 076661723..48cd60e7a 100644
--- a/otherlibs/win32unix/close.c
+++ b/otherlibs/win32unix/close.c
@@ -18,9 +18,16 @@
CAMLprim value unix_close(value fd)
{
- if (! CloseHandle(Handle_val(fd))) {
- win32_maperr(GetLastError());
- uerror("close", Nothing);
+ if (Descr_kind_val(fd) == KIND_SOCKET) {
+ if (closesocket(Socket_val(fd)) != 0) {
+ win32_maperr(WSAGetLastError());
+ uerror("close", Nothing);
+ }
+ } else {
+ if (! CloseHandle(Handle_val(fd))) {
+ win32_maperr(GetLastError());
+ uerror("close", Nothing);
+ }
}
return Val_unit;
}