fix #19244 - solves the problem of the InAddr object constructor in Windows. (#19259)

* Update winlean.nim

* Update tnet_ll.nim
This commit is contained in:
rockcavera
2021-12-17 05:01:33 -03:00
committed by GitHub
parent 609388e33f
commit 5ddaf3e1fb
2 changed files with 7 additions and 1 deletions

View File

@@ -478,7 +478,7 @@ type
PSockAddr = ptr SockAddr
InAddr* {.importc: "IN_ADDR", header: "winsock2.h".} = object
InAddr* {.importc: "IN_ADDR", header: "winsock2.h", union.} = object
s_addr*: uint32 # IP address
Sockaddr_in* {.importc: "SOCKADDR_IN",

View File

@@ -26,6 +26,7 @@ suite "inet_ntop tests":
# regular
var ip4 = InAddr()
ip4.s_addr = 0x10111213'u32
check: ip4.s_addr == 0x10111213'u32
var buff: array[0..255, char]
let r = inet_ntop(AF_INET, cast[pointer](ip4.s_addr.addr), buff[0].addr, buff.len.int32)
@@ -43,3 +44,8 @@ suite "inet_ntop tests":
let r = inet_ntop(AF_INET6, cast[pointer](ip6[0].addr), buff[0].addr, buff.len.int32)
let res = if r == nil: "" else: $r
check: not ipv6Support or res == "10:110:20:120:30:130:40:140"
test "InAddr":
# issue 19244
var ip4 = InAddr(s_addr: 0x10111213'u32)
check: ip4.s_addr == 0x10111213'u32