Resolve bugs based on unreliable bytesReceived value.

This commit is contained in:
cheatfate 2016-05-12 21:11:42 +03:00
commit 6fa6fdeb34
2 changed files with 21 additions and 53 deletions

View file

@ -759,6 +759,7 @@ const
WSAENETRESET* = 10052
WSAETIMEDOUT* = 10060
ERROR_NETNAME_DELETED* = 64
STATUS_PENDING* = 0x103
proc createIoCompletionPort*(FileHandle: Handle, ExistingCompletionPort: Handle,
CompletionKey: ULONG_PTR,
@ -775,6 +776,12 @@ proc getOverlappedResult*(hFile: Handle, lpOverlapped: POVERLAPPED,
lpNumberOfBytesTransferred: var DWORD, bWait: WINBOOL): WINBOOL{.
stdcall, dynlib: "kernel32", importc: "GetOverlappedResult".}
# this is copy of HasOverlappedIoCompleted() macro from <winbase.h>
# because we have declared own OVERLAPPED structure with member names not
# compatible with original names.
template hasOverlappedIoCompleted*(lpOverlapped): bool =
(cast[uint](lpOverlapped.internal) != STATUS_PENDING)
const
IOC_OUT* = 0x40000000
IOC_IN* = 0x80000000