Merge pull request #9057 from LemonBoy/fix-9055
Make getSockDomain work with AF_UNIX sockets
This commit is contained in:
commit
acf4e02514
1 changed files with 4 additions and 7 deletions
|
|
@ -456,13 +456,10 @@ proc getSockDomain*(socket: SocketHandle): Domain =
|
||||||
if getsockname(socket, cast[ptr SockAddr](addr(name)),
|
if getsockname(socket, cast[ptr SockAddr](addr(name)),
|
||||||
addr(namelen)) == -1'i32:
|
addr(namelen)) == -1'i32:
|
||||||
raiseOSError(osLastError())
|
raiseOSError(osLastError())
|
||||||
if name.sin6_family.cint == nativeAfInet:
|
try:
|
||||||
result = AF_INET
|
result = toKnownDomain(name.sin6_family.cint).get()
|
||||||
elif name.sin6_family.cint == nativeAfInet6:
|
except UnpackError:
|
||||||
result = AF_INET6
|
raise newException(IOError, "Unknown socket family in getSockDomain")
|
||||||
else:
|
|
||||||
raiseOSError(osLastError(), "unknown socket family in getSockFamily")
|
|
||||||
|
|
||||||
|
|
||||||
proc getAddrString*(sockAddr: ptr SockAddr): string =
|
proc getAddrString*(sockAddr: ptr SockAddr): string =
|
||||||
## return the string representation of address within sockAddr
|
## return the string representation of address within sockAddr
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue