Source
pub fn getOsSockLen(self: Address) posix.socklen_t {
switch (self.any.family) {
posix.AF.INET => return self.in.getOsSockLen(),
posix.AF.INET6 => return self.in6.getOsSockLen(),
posix.AF.UNIX => {
if (!has_unix_sockets) {
unreachable;
}
// Using the full length of the structure here is more portable than returning
// the number of bytes actually used by the currently stored path.
// This also is correct regardless if we are passing a socket address to the kernel
// (e.g. in bind, connect, sendto) since we ensure the path is 0 terminated in
// initUnix() or if we are receiving a socket address from the kernel and must
// provide the full buffer size (e.g. getsockname, getpeername, recvfrom, accept).
//
// To access the path, std.mem.sliceTo(&address.un.path, 0) should be used.
return @as(posix.socklen_t, @intCast(@sizeOf(posix.sockaddr.un)));
},
else => unreachable,
}
}