Skip to content

Commit

Permalink
Merge pull request #9057 from LemonBoy/fix-9055
Browse files Browse the repository at this point in the history
Make getSockDomain work with AF_UNIX sockets
  • Loading branch information
dom96 committed Sep 25, 2018
2 parents 27b6226 + d87606b commit acf4e02
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/pure/nativesockets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,10 @@ proc getSockDomain*(socket: SocketHandle): Domain =
if getsockname(socket, cast[ptr SockAddr](addr(name)),
addr(namelen)) == -1'i32:
raiseOSError(osLastError())
if name.sin6_family.cint == nativeAfInet:
result = AF_INET
elif name.sin6_family.cint == nativeAfInet6:
result = AF_INET6
else:
raiseOSError(osLastError(), "unknown socket family in getSockFamily")

try:
result = toKnownDomain(name.sin6_family.cint).get()
except UnpackError:
raise newException(IOError, "Unknown socket family in getSockDomain")

proc getAddrString*(sockAddr: ptr SockAddr): string =
## return the string representation of address within sockAddr
Expand Down

0 comments on commit acf4e02

Please sign in to comment.