All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jnr.unixsocket.UnixSocketOptions Maven / Gradle / Ivy

/*
 * Copyright (C) 2016 Fritz Elfert
 *
 * This file is part of the JNR project.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package jnr.unixsocket;

import java.net.SocketOption;

/**
 * Defines common socket options for AF_UNIX sockets.
 */
public final class UnixSocketOptions {

    private static class GenericOption implements SocketOption {
        private final String name;
        private final Class type;
        GenericOption(String name, Class type) {
            this.name = name;
            this.type = type;
        }
        @Override public String name() { return name; }
        @Override public Class type() { return type; }
        @Override public String toString() { return name; }
    }

    /**
     * Get/Set size of the socket send buffer.
     */
    public static final SocketOption SO_SNDBUF =
        new GenericOption("SO_SNDBUF", Integer.class);

    /**
     * Get/Set send timeout.
     */
    public static final SocketOption SO_SNDTIMEO =
        new GenericOption("SO_SNDTIMEO", Integer.class);

    /**
     * Get/Set size of the socket receive buffer.
     */
    public static final SocketOption SO_RCVBUF =
        new GenericOption("SO_RCVBUF", Integer.class);

    /**
     * Get/Set receive timeout.
     */
    public static final SocketOption SO_RCVTIMEO =
        new GenericOption("SO_RCVTIMEO", Integer.class);

    /**
     * Keep connection alive.
     */
    public static final SocketOption SO_KEEPALIVE =
        new GenericOption("SO_KEEPALIVE", Boolean.class);

    /**
     * Fetch peer credentials.
     */
    public static final SocketOption SO_PEERCRED =
        new GenericOption("SO_PEERCRED", Credentials.class);

    /**
     * Enable credential transmission.
     */
    public static final SocketOption SO_PASSCRED =
        new GenericOption("SO_PASSCRED", Boolean.class);

}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy