微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java.net.SocketOption的实例源码

项目:Openjsharp    文件AsynchronousServerSocketChannelImpl.java   
@Override
public final <T> AsynchronousServerSocketChannel setoption(Socketoption<T> name,T value)
    throws IOException
{
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            isReuseAddress = (Boolean)value;
        } else {
            Net.setSocketoption(fd,Net.UNSPEC,name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:Openjsharp    文件AsynchronousServerSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:Openjsharp    文件AsynchronousSocketChannelImpl.java   
@Override
public final <T> AsynchronousSocketChannel setoption(Socketoption<T> name,T value)
    throws IOException
{
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (writeShutdown)
            throw new IOException("Connection has been shutdown for writing");
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            isReuseAddress = (Boolean)value;
        } else {
            Net.setSocketoption(fd,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:Openjsharp    文件AsynchronousSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:jdk8u-jdk    文件AsynchronousServerSocketChannelImpl.java   
@Override
public final <T> AsynchronousServerSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:jdk8u-jdk    文件AsynchronousServerSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:jdk8u-jdk    文件AsynchronousSocketChannelImpl.java   
@Override
public final <T> AsynchronousSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:jdk8u-jdk    文件AsynchronousSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:openjdk-jdk10    文件AsynchronousServerSocketChannelImpl.java   
@Override
public final <T> AsynchronousServerSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:openjdk-jdk10    文件AsynchronousServerSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:openjdk-jdk10    文件AsynchronousSocketChannelImpl.java   
@Override
public final <T> AsynchronousSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:openjdk-jdk10    文件AsynchronousSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:openjdk-jdk10    文件ExtendedSocketoptions.java   
@Override
public void setoption(FileDescriptor fd,Socketoption<?> option,Object value)
    throws SocketException
{
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
        sm.checkPermission(new NetworkPermission("setoption." + option.name()));

    if (fd == null || !fd.valid())
        throw new SocketException("socket closed");

    if (option == SO_FLOW_SLA) {
        assert flowSupported;
        SocketFlow flow = checkValueType(value,option.type());
        setFlowOption(fd,flow);
    } else {
        throw new InternalError("Unexpected option " + option);
    }
}
项目:openjdk-jdk10    文件ExtendedSocketoptions.java   
@Override
public Object getoption(FileDescriptor fd,Socketoption<?> option)
    throws SocketException
{
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
        sm.checkPermission(new NetworkPermission("getoption." + option.name()));

    if (fd == null || !fd.valid())
        throw new SocketException("socket closed");

    if (option == SO_FLOW_SLA) {
        assert flowSupported;
        SocketFlow flow = SocketFlow.create();
        getFlowOption(fd,flow);
        return flow;
    } else {
        throw new InternalError("Unexpected option " + option);
    }
}
项目:openjdk9    文件AsynchronousServerSocketChannelImpl.java   
@Override
public final <T> AsynchronousServerSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:openjdk9    文件AsynchronousServerSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:openjdk9    文件AsynchronousSocketChannelImpl.java   
@Override
public final <T> AsynchronousSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:openjdk9    文件AsynchronousSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:openjdk9    文件ExtendedSocketoptions.java   
@Override
public void setoption(FileDescriptor fd,flow);
    } else {
        throw new InternalError("Unexpected option " + option);
    }
}
项目:openjdk9    文件ExtendedSocketoptions.java   
@Override
public Object getoption(FileDescriptor fd,flow);
        return flow;
    } else {
        throw new InternalError("Unexpected option " + option);
    }
}
项目:jdk8u_jdk    文件AsynchronousServerSocketChannelImpl.java   
@Override
public final <T> AsynchronousServerSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:jdk8u_jdk    文件AsynchronousServerSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:jdk8u_jdk    文件AsynchronousSocketChannelImpl.java   
@Override
public final <T> AsynchronousSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:jdk8u_jdk    文件AsynchronousSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件AsynchronousServerSocketChannelImpl.java   
@Override
public final <T> AsynchronousServerSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件AsynchronousServerSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件AsynchronousSocketChannelImpl.java   
@Override
public final <T> AsynchronousSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:lookaside_java-1.8.0-openjdk    文件AsynchronousSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:j2objc    文件NIoUtils.java   
/**
 * Sets the supplied option on the channel to have the value if option is a member of
 * allowedOptions.
 *
 * @throws IOException
 *          if the value Could not be set due to IO errors.
 * @throws IllegalArgumentException
 *          if the socket option or the value is invalid.
 * @throws UnsupportedOperationException
 *          if the option is not a member of allowedOptions.
 * @throws ClosedChannelException
 *          if the channel is closed
 */
public static <T> void setSocketoption(
        FileDescriptorChannel channel,Set<Socketoption<?>> allowedOptions,Socketoption<T> option,T value)
        throws IOException {

    if (!(option instanceof StandardSocketoptions.socketoptionImpl)) {
        throw new IllegalArgumentException("Socketoption must come from StandardSocketoptions");
    }
    if (!allowedOptions.contains(option)) {
        throw new UnsupportedOperationException(
                option + " is not supported for this type of socket");
    }
    if (!channel.getFD().valid()) {
        throw new ClosedChannelException();
    }
    ((StandardSocketoptions.socketoptionImpl<T>) option).setValue(channel.getFD(),value);
}
项目:j2objc    文件NIoUtils.java   
/**
 * Gets the supplied option from the channel if option is a member of allowedOptions.
 *
 * @throws IOException
 *          if the value Could not be read due to IO errors.
 * @throws IllegalArgumentException
 *          if the socket option is invalid.
 * @throws UnsupportedOperationException
 *          if the option is not a member of allowedOptions.
 * @throws ClosedChannelException
 *          if the channel is closed
 */
public static <T> T getSocketoption(
        FileDescriptorChannel channel,Socketoption<T> option)
        throws IOException {

    if (!(option instanceof StandardSocketoptions.socketoptionImpl)) {
        throw new IllegalArgumentException("Socketoption must come from StandardSocketoptions");
    }
    if (!allowedOptions.contains(option)) {
        throw new UnsupportedOperationException(
                option + " is not supported for this type of socket");
    }
    if (!channel.getFD().valid()) {
        throw new ClosedChannelException();
    }
    return ((StandardSocketoptions.socketoptionImpl<T>) option).getValue(channel.getFD());
}
项目:jephyr    文件NioSocketImpl.java   
private static Socketoption<?> findOption(int optID) throws SocketException {
    switch (optID) {
        case TCP_NODELAY:
            return StandardSocketoptions.TCP_NODELAY;
        case SO_REUSEADDR:
            return StandardSocketoptions.so_REUSEADDR;
        case SO_broADCAST:
            return StandardSocketoptions.so_broADCAST;
        case IP_MULTICAST_IF:
            return StandardSocketoptions.IP_MULTICAST_IF;
        case IP_MULTICAST_LOOP:
            return StandardSocketoptions.IP_MULTICAST_LOOP;
        case IP_TOS:
            return StandardSocketoptions.IP_TOS;
        case SO_LINGER:
            return StandardSocketoptions.so_LINGER;
        case SO_SNDBUF:
            return StandardSocketoptions.so_SNDBUF;
        case SO_RCVBUF:
            return StandardSocketoptions.so_RCVBUF;
        case SO_KEEPALIVE:
            return StandardSocketoptions.so_KEEPALIVE;
        default:
            throw new SocketException("unrecognized TCP option: " + optID);
    }
}
项目:infobip-open-jdk-8    文件AsynchronousServerSocketChannelImpl.java   
@Override
public final <T> AsynchronousServerSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:infobip-open-jdk-8    文件AsynchronousServerSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:infobip-open-jdk-8    文件AsynchronousSocketChannelImpl.java   
@Override
public final <T> AsynchronousSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:infobip-open-jdk-8    文件AsynchronousSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:jdk8u-dev-jdk    文件AsynchronousServerSocketChannelImpl.java   
@Override
public final <T> AsynchronousServerSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:jdk8u-dev-jdk    文件AsynchronousServerSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:jdk8u-dev-jdk    文件AsynchronousSocketChannelImpl.java   
@Override
public final <T> AsynchronousSocketChannel setoption(Socketoption<T> name,value);
        }
        return this;
    } finally {
        end();
    }
}
项目:jdk8u-dev-jdk    文件AsynchronousSocketChannelImpl.java   
@Override
@SuppressWarnings("unchecked")
public final <T> T getoption(Socketoption<T> name) throws IOException {
    if (name == null)
        throw new NullPointerException();
    if (!supportedOptions().contains(name))
        throw new UnsupportedOperationException("'" + name + "' not supported");

    try {
        begin();
        if (name == StandardSocketoptions.so_REUSEADDR &&
                Net.useExclusiveBind())
        {
            // SO_REUSEADDR emulated when using exclusive bind
            return (T)Boolean.valueOf(isReuseAddress);
        }
        return (T) Net.getSocketoption(fd,name);
    } finally {
        end();
    }
}
项目:GitHub    文件DelegatingSSLSocket.java   
public <T> Socket setoption(Socketoption<T> name,T value) throws IOException {
  try {
    SSLSocket.class.getmethod("setoption",Socketoption.class,Object.class).invoke(delegate,value);
    return this;
  } catch (illegalaccessexception | InvocationTargetException | NoSuchMethodException e) {
    throw new AssertionError();
  }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。