diff options
author | LemonBoy <thatlemon@gmail.com> | 2018-09-19 09:24:30 +0200 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2018-09-19 12:33:11 +0200 |
commit | a27429304e77ced5b9ba5729e47d6d6c7b7dae5c (patch) | |
tree | eff2d0b0f26c407d291a62b5ea5381c4ec5344e3 /lib/deprecated | |
parent | a892d519a60e08212ea05e99bb9f858e6673ee6b (diff) | |
download | Nim-a27429304e77ced5b9ba5729e47d6d6c7b7dae5c.tar.gz |
Convert *_family fields to cushort
Fixes #9008
Diffstat (limited to 'lib/deprecated')
-rw-r--r-- | lib/deprecated/pure/sockets.nim | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/deprecated/pure/sockets.nim b/lib/deprecated/pure/sockets.nim index 76a9044d8..ed15f67e2 100644 --- a/lib/deprecated/pure/sockets.nim +++ b/lib/deprecated/pure/sockets.nim @@ -223,7 +223,7 @@ template htons(x: uint16): uint16 = sockets.ntohs(x) when defined(Posix): - proc toInt(domain: Domain): TSa_Family = + proc toInt(domain: Domain): cint = case domain of AF_UNIX: result = posix.AF_UNIX of AF_INET: result = posix.AF_INET @@ -463,9 +463,9 @@ proc bindAddr*(socket: Socket, port = Port(0), address = "") {. if address == "": var name: Sockaddr_in when defined(Windows): - name.sin_family = int16(ord(AF_INET)) + name.sin_family = uint16(ord(AF_INET)) else: - name.sin_family = posix.AF_INET + name.sin_family = uint16(posix.AF_INET) name.sin_port = sockets.htons(uint16(port)) name.sin_addr.s_addr = sockets.htonl(INADDR_ANY) if bindSocket(socket.fd, cast[ptr SockAddr](addr(name)), @@ -485,9 +485,9 @@ proc getSockName*(socket: Socket): Port = ## returns the socket's associated port number. var name: Sockaddr_in when defined(Windows): - name.sin_family = int16(ord(AF_INET)) + name.sin_family = uint16(ord(AF_INET)) else: - name.sin_family = posix.AF_INET + name.sin_family = uint16(posix.AF_INET) #name.sin_port = htons(cint16(port)) #name.sin_addr.s_addr = htonl(INADDR_ANY) var namelen = sizeof(name).SockLen @@ -729,9 +729,9 @@ proc getHostByAddr*(ip: string): Hostent {.tags: [ReadIOEffect].} = when defined(windows): result.addrtype = Domain(s.h_addrtype) else: - if s.h_addrtype == posix.AF_INET: + if s.h_addrtype.cint == posix.AF_INET: result.addrtype = AF_INET - elif s.h_addrtype == posix.AF_INET6: + elif s.h_addrtype.cint == posix.AF_INET6: result.addrtype = AF_INET6 else: raiseOSError(osLastError(), "unknown h_addrtype") @@ -750,9 +750,9 @@ proc getHostByName*(name: string): Hostent {.tags: [ReadIOEffect].} = when defined(windows): result.addrtype = Domain(s.h_addrtype) else: - if s.h_addrtype == posix.AF_INET: + if s.h_addrtype.cint == posix.AF_INET: result.addrtype = AF_INET - elif s.h_addrtype == posix.AF_INET6: + elif s.h_addrtype.cint == posix.AF_INET6: result.addrtype = AF_INET6 else: raiseOSError(osLastError(), "unknown h_addrtype") |