/** * Retrieves the path. * @return The path of this AF_UNIX address. * Note: On Linux, can contain a leading NUL byte, if this address * resides in abstract namespace. */ public String path() { return address.getPath(); }
/** * Updates the file system path of this socket address. * In order to support abstract namespaces, this MUST be * called after any native syscall that sets this * path struct like getsockname(), getpeername(), accept(). * * @param len the value of the addrlen var, set by the above syscalls. */ void updatePath(final int len) { if (currentOS == OS.LINUX) { // Linux always returns an accurate length in // order to support abstract namespace, where // path STARTS with a NUL byte. cachedPath = len == HEADER_LENGTH ? "" : getPath(len - HEADER_LENGTH); } else { // All others might return a len > 0 (typically 14) AND the path is terminated // by a NUL byte if it is shorter than sizeof(sun_path) cachedPath = getPathField().get(); int slen = len - HEADER_LENGTH; if (slen <= 0) { cachedPath = ""; } else { if (slen < getPathField().length() && slen < cachedPath.length()) { cachedPath = cachedPath.substring(0, slen); } } } }
@Override public String toString() { return "[family=" + address.getFamily() + " path=" + address.getPath() + "]"; } }