Home / Type/ SocketProtocolFamily Type — netty Architecture

SocketProtocolFamily Type — netty Architecture

Architecture documentation for the SocketProtocolFamily type/interface in SocketProtocolFamily.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  fb82569f_ea57_c5ba_5c48_4457e1aba86f["SocketProtocolFamily"]
  51d0543d_5c96_2171_9178_10b232d7d6f4["SocketProtocolFamily.java"]
  fb82569f_ea57_c5ba_5c48_4457e1aba86f -->|defined in| 51d0543d_5c96_2171_9178_10b232d7d6f4
  style fb82569f_ea57_c5ba_5c48_4457e1aba86f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/socket/SocketProtocolFamily.java lines 24–87

public enum SocketProtocolFamily implements ProtocolFamily {
    /**
     * IPv4
     */
    INET,
    /**
     * IPv6
     */
    INET6,
    /**
     * Unix Domain Socket
     */
    UNIX;

    /**
     * Return a {@link ProtocolFamily} that is "known" by the JDK itself and represent the same as
     * {@link SocketProtocolFamily}.
     *
     * @return the JDK {@link ProtocolFamily}.
     * @throws UnsupportedOperationException if it can't be converted.
     */
    public ProtocolFamily toJdkFamily() {
        switch (this) {
            case INET:
                return StandardProtocolFamily.INET;
            case INET6:
                return StandardProtocolFamily.INET6;
            case UNIX:
                // Just use valueOf as we compile with Java11. If the JDK does not support unix domain sockets, this
                // will throw.
                return StandardProtocolFamily.valueOf("UNIX");
            default:
                throw new UnsupportedOperationException(
                        "ProtocolFamily cant be converted to something that is known by the JDKi: " + this);
        }
    }

    /**
     * Return the {@link SocketProtocolFamily} for the given {@link ProtocolFamily} if possible.
     *
     * @param family    the JDK {@link ProtocolFamily} to convert.
     * @return          the {@link SocketProtocolFamily}.
     * @throws          UnsupportedOperationException if it can't be converted.
     */
    public static SocketProtocolFamily of(ProtocolFamily family) {
        if (family instanceof StandardProtocolFamily) {
            switch ((StandardProtocolFamily) family) {
                case INET:
                    return INET;
                case INET6:
                    return INET6;
                default:
                    // Just compare the name as we compile with Java11
                    if (UNIX.name().equals(family.name())) {
                        return UNIX;
                    }
                    // Fall-through
            }
        } else if (family instanceof SocketProtocolFamily) {
            return (SocketProtocolFamily) family;
        }
        throw new UnsupportedOperationException("ProtocolFamily is not supported: " + family);
    }
}

Frequently Asked Questions

What is the SocketProtocolFamily type?
SocketProtocolFamily is a type/interface in the netty codebase, defined in transport/src/main/java/io/netty/channel/socket/SocketProtocolFamily.java.
Where is SocketProtocolFamily defined?
SocketProtocolFamily is defined in transport/src/main/java/io/netty/channel/socket/SocketProtocolFamily.java at line 24.

Analyze Your Own Codebase

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

Try Supermodel Free