summary refs log tree commit diff stats
path: root/lib/windows
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2013-10-23 18:07:00 +0100
committerDominik Picheta <dominikpicheta@googlemail.com>2013-10-23 18:07:00 +0100
commit8231deffd06952aa63a5f2dda0c5665ce90061ab (patch)
tree8e41975f5a5d7c68d573ba86e93e2c2fd5689548 /lib/windows
parenta352109adebe6680cea5337b7e4c8678c588fc53 (diff)
downloadNim-8231deffd06952aa63a5f2dda0c5665ce90061ab.tar.gz
Made TSocketHandle distinct and fixed problems it caused for SSL.
Diffstat (limited to 'lib/windows')
-rw-r--r--lib/windows/winlean.nim12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/windows/winlean.nim b/lib/windows/winlean.nim
index 40b24cc0a..6f72319ba 100644
--- a/lib/windows/winlean.nim
+++ b/lib/windows/winlean.nim
@@ -389,8 +389,6 @@ type
     h_addrtype*: int16
     h_length*: int16
     h_addr_list*: cstringArray
-    
-  TSocketHandle* = int # Make distinct? Is this the right place for this?
   
   TFdSet* {.pure, final.} = object
     fd_count*: cint # unsigned
@@ -411,8 +409,18 @@ type
 
   Tsocklen* = cuint
 
+when hostCPU == "amd64":
+  type
+    TSocketHandle* = distinct int # on WIN64 `SOCKET` is UINT_PTR
+else:
+  type
+    TSocketHandle* = distinct cuint # on WIN32 `SOCKET` is U_INT (unsigned int)
+
 var
   SOMAXCONN* {.importc, header: "Winsock2.h".}: cint
+  INVALID_SOCKET* {.importc, header: "Winsock2.h".}: cint
+
+proc `==`*(x, y: TSocketHandle): bool {.borrow.}
 
 proc getservbyname*(name, proto: cstring): ptr TServent {.
   stdcall, importc: "getservbyname", dynlib: ws2dll.}