Fixed socket compilation problems on Windows.
This commit is contained in:
parent
8231deffd0
commit
f695bb0b6f
2 changed files with 10 additions and 10 deletions
|
|
@ -130,10 +130,10 @@ let
|
|||
InvalidSocket*: TSocket = nil ## invalid socket
|
||||
|
||||
when defined(windows):
|
||||
const
|
||||
let
|
||||
OSInvalidSocket = winlean.INVALID_SOCKET
|
||||
else:
|
||||
const
|
||||
let
|
||||
OSInvalidSocket = posix.INVALID_SOCKET
|
||||
|
||||
proc newTSocket(fd: TSocketHandle, isBuff: bool): TSocket =
|
||||
|
|
|
|||
|
|
@ -334,6 +334,13 @@ const
|
|||
|
||||
proc WSAGetLastError*(): cint {.importc: "WSAGetLastError", dynlib: ws2dll.}
|
||||
|
||||
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)
|
||||
|
||||
type
|
||||
TWSAData* {.pure, final, importc: "WSADATA", header: "Winsock2.h".} = object
|
||||
wVersion, wHighVersion: int16
|
||||
|
|
@ -409,16 +416,9 @@ 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
|
||||
INVALID_SOCKET* {.importc, header: "Winsock2.h".}: TSocketHandle
|
||||
|
||||
proc `==`*(x, y: TSocketHandle): bool {.borrow.}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue