Home / Class/ UnixDomainSocket Class — spring-boot Architecture

UnixDomainSocket Class — spring-boot Architecture

Architecture documentation for the UnixDomainSocket class in UnixDomainSocket.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/socket/UnixDomainSocket.java lines 35–102

public final class UnixDomainSocket extends AbstractSocket {

	/**
	 * Create a new {@link Socket} for the given path.
	 * @param path the path to the domain socket
	 * @return a {@link Socket} instance
	 * @throws IOException if the socket cannot be opened
	 */
	public static Socket get(String path) throws IOException {
		return new UnixDomainSocket(path);
	}

	private final SocketAddress socketAddress;

	private final SocketChannel socketChannel;

	private UnixDomainSocket(String path) throws IOException {
		this.socketAddress = UnixDomainSocketAddress.of(path);
		this.socketChannel = SocketChannel.open(this.socketAddress);
	}

	@Override
	public InputStream getInputStream() throws IOException {
		if (isClosed()) {
			throw new SocketException("Socket is closed");
		}
		if (!isConnected()) {
			throw new SocketException("Socket is not connected");
		}
		if (isInputShutdown()) {
			throw new SocketException("Socket input is shutdown");
		}

		return Channels.newInputStream(this.socketChannel);
	}

	@Override
	public OutputStream getOutputStream() throws IOException {
		if (isClosed()) {
			throw new SocketException("Socket is closed");
		}
		if (!isConnected()) {
			throw new SocketException("Socket is not connected");
		}
		if (isOutputShutdown()) {
			throw new SocketException("Socket output is shutdown");
		}

		return Channels.newOutputStream(this.socketChannel);
	}

	@Override
	public SocketAddress getLocalSocketAddress() {
		return this.socketAddress;
	}

	@Override
	public SocketAddress getRemoteSocketAddress() {
		return this.socketAddress;
	}

	@Override
	public void close() throws IOException {
		super.close();
		this.socketChannel.close();
	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free