fixes #1689
This commit is contained in:
parent
c00a3fdc5b
commit
b7c8063816
4 changed files with 28 additions and 9 deletions
|
|
@ -419,12 +419,12 @@ when defined(windows) or defined(nimdoc):
|
|||
var acceptExPtr: pointer = nil
|
||||
var getAcceptExSockAddrsPtr: pointer = nil
|
||||
|
||||
proc initPointer(s: SocketHandle, func: var pointer, guid: var TGUID): bool =
|
||||
proc initPointer(s: SocketHandle, fun: var pointer, guid: var TGUID): bool =
|
||||
# Ref: https://github.com/powdahound/twisted/blob/master/twisted/internet/iocpreactor/iocpsupport/winsock_pointers.c
|
||||
var bytesRet: Dword
|
||||
func = nil
|
||||
fun = nil
|
||||
result = WSAIoctl(s, SIO_GET_EXTENSION_FUNCTION_POINTER, addr guid,
|
||||
sizeof(TGUID).Dword, addr func, sizeof(pointer).Dword,
|
||||
sizeof(TGUID).Dword, addr fun, sizeof(pointer).Dword,
|
||||
addr bytesRet, nil, nil) == 0
|
||||
|
||||
proc initAll() =
|
||||
|
|
@ -440,12 +440,12 @@ when defined(windows) or defined(nimdoc):
|
|||
lpSendBuffer: pointer, dwSendDataLength: Dword,
|
||||
lpdwBytesSent: PDword, lpOverlapped: POVERLAPPED): bool =
|
||||
if connectExPtr.isNil: raise newException(ValueError, "Need to initialise ConnectEx().")
|
||||
let func =
|
||||
let fun =
|
||||
cast[proc (s: SocketHandle, name: ptr TSockAddr, namelen: cint,
|
||||
lpSendBuffer: pointer, dwSendDataLength: Dword,
|
||||
lpdwBytesSent: PDword, lpOverlapped: POVERLAPPED): bool {.stdcall,gcsafe.}](connectExPtr)
|
||||
|
||||
result = func(s, name, namelen, lpSendBuffer, dwSendDataLength, lpdwBytesSent,
|
||||
result = fun(s, name, namelen, lpSendBuffer, dwSendDataLength, lpdwBytesSent,
|
||||
lpOverlapped)
|
||||
|
||||
proc acceptEx(listenSock, acceptSock: SocketHandle, lpOutputBuffer: pointer,
|
||||
|
|
@ -453,12 +453,12 @@ when defined(windows) or defined(nimdoc):
|
|||
dwRemoteAddressLength: Dword, lpdwBytesReceived: PDword,
|
||||
lpOverlapped: POVERLAPPED): bool =
|
||||
if acceptExPtr.isNil: raise newException(ValueError, "Need to initialise AcceptEx().")
|
||||
let func =
|
||||
let fun =
|
||||
cast[proc (listenSock, acceptSock: SocketHandle, lpOutputBuffer: pointer,
|
||||
dwReceiveDataLength, dwLocalAddressLength,
|
||||
dwRemoteAddressLength: Dword, lpdwBytesReceived: PDword,
|
||||
lpOverlapped: POVERLAPPED): bool {.stdcall,gcsafe.}](acceptExPtr)
|
||||
result = func(listenSock, acceptSock, lpOutputBuffer, dwReceiveDataLength,
|
||||
result = fun(listenSock, acceptSock, lpOutputBuffer, dwReceiveDataLength,
|
||||
dwLocalAddressLength, dwRemoteAddressLength, lpdwBytesReceived,
|
||||
lpOverlapped)
|
||||
|
||||
|
|
@ -469,14 +469,14 @@ when defined(windows) or defined(nimdoc):
|
|||
if getAcceptExSockAddrsPtr.isNil:
|
||||
raise newException(ValueError, "Need to initialise getAcceptExSockAddrs().")
|
||||
|
||||
let func =
|
||||
let fun =
|
||||
cast[proc (lpOutputBuffer: pointer,
|
||||
dwReceiveDataLength, dwLocalAddressLength,
|
||||
dwRemoteAddressLength: Dword, LocalSockaddr: ptr ptr TSockAddr,
|
||||
LocalSockaddrLength: LPInt, RemoteSockaddr: ptr ptr TSockAddr,
|
||||
RemoteSockaddrLength: LPInt) {.stdcall,gcsafe.}](getAcceptExSockAddrsPtr)
|
||||
|
||||
func(lpOutputBuffer, dwReceiveDataLength, dwLocalAddressLength,
|
||||
fun(lpOutputBuffer, dwReceiveDataLength, dwLocalAddressLength,
|
||||
dwRemoteAddressLength, LocalSockaddr, LocalSockaddrLength,
|
||||
RemoteSockaddr, RemoteSockaddrLength)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue