Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/classes/sun/net/NetHooks.java
32287 views
/*1* Copyright (c) 2009, 2010, 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*/2425package sun.net;2627import java.net.InetAddress;28import java.io.FileDescriptor;29import java.io.IOException;30import java.security.AccessController;31import java.security.PrivilegedAction;32import sun.security.action.GetPropertyAction;3334/**35* Defines static methods to be invoked prior to binding or connecting TCP sockets.36*/3738public final class NetHooks {3940/**41* A provider with hooks to allow sockets be converted prior to binding or42* connecting a TCP socket.43*44* <p> Concrete implementations of this class should define a zero-argument45* constructor and implement the abstract methods specified below.46*/47public static abstract class Provider {48/**49* Initializes a new instance of this class.50*/51protected Provider() {}5253/**54* Invoked prior to binding a TCP socket.55*/56public abstract void implBeforeTcpBind(FileDescriptor fdObj,57InetAddress address,58int port)59throws IOException;6061/**62* Invoked prior to connecting an unbound TCP socket.63*/64public abstract void implBeforeTcpConnect(FileDescriptor fdObj,65InetAddress address,66int port)67throws IOException;68}6970/**71* For now, we load the SDP provider on Solaris. In the future this may72* be changed to use the ServiceLoader facility to allow the deployment of73* other providers.74*/75private static final Provider provider = new sun.net.sdp.SdpProvider();7677/**78* Invoke prior to binding a TCP socket.79*/80public static void beforeTcpBind(FileDescriptor fdObj,81InetAddress address,82int port)83throws IOException84{85provider.implBeforeTcpBind(fdObj, address, port);86}8788/**89* Invoke prior to connecting an unbound TCP socket.90*/91public static void beforeTcpConnect(FileDescriptor fdObj,92InetAddress address,93int port)94throws IOException95{96provider.implBeforeTcpConnect(fdObj, address, port);97}98}99100101