Path: blob/master/src/java.base/unix/classes/java/net/PlainSocketImpl.java
41134 views
/*1* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/24package java.net;2526import java.io.IOException;27import java.util.Set;28import java.util.HashSet;29import sun.net.ext.ExtendedSocketOptions;3031/*32* On Unix systems we simply delegate to native methods.33*34* @author Chris Hegarty35*/3637class PlainSocketImpl extends AbstractPlainSocketImpl38{39static {40initProto();41}4243/**44* Constructs an empty instance.45*/46PlainSocketImpl(boolean isServer) {47super(isServer);48}4950protected void socketSetOption(int opt, boolean b, Object val) throws SocketException {51if (opt == SocketOptions.SO_REUSEPORT &&52!supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {53throw new UnsupportedOperationException("unsupported option");54}55try {56socketSetOption0(opt, b, val);57} catch (SocketException se) {58if (!isConnected)59throw se;60}61}6263void socketCreate(boolean stream) throws IOException {64socketCreate(stream, isServer);65}6667native void socketCreate(boolean stream, boolean isServer) throws IOException;6869native void socketConnect(InetAddress address, int port, int timeout)70throws IOException;7172native void socketBind(InetAddress address, int port)73throws IOException;7475native void socketListen(int count) throws IOException;7677native void socketAccept(SocketImpl s) throws IOException;7879native int socketAvailable() throws IOException;8081native void socketClose0(boolean useDeferredClose) throws IOException;8283native void socketShutdown(int howto) throws IOException;8485static native void initProto();8687native void socketSetOption0(int cmd, boolean on, Object value)88throws SocketException;8990native int socketGetOption(int opt, Object iaContainerObj) throws SocketException;9192native void socketSendUrgentData(int data) throws IOException;93}949596