Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/unix/classes/sun/net/NetHooks.java
41133 views
1
/*
2
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package sun.net;
27
28
import java.net.InetAddress;
29
import java.io.FileDescriptor;
30
import java.io.IOException;
31
32
/**
33
* Defines static methods to be invoked prior to binding or connecting TCP sockets.
34
*/
35
36
public final class NetHooks {
37
38
/**
39
* A provider with hooks to allow sockets be converted prior to binding or
40
* connecting a TCP socket.
41
*
42
* <p> Concrete implementations of this class should define a zero-argument
43
* constructor and implement the abstract methods specified below.
44
*/
45
public abstract static class Provider {
46
/**
47
* Initializes a new instance of this class.
48
*/
49
protected Provider() {}
50
51
/**
52
* Invoked prior to binding a TCP socket.
53
*/
54
public abstract void implBeforeTcpBind(FileDescriptor fdObj,
55
InetAddress address,
56
int port)
57
throws IOException;
58
59
/**
60
* Invoked prior to connecting an unbound TCP socket.
61
*/
62
public abstract void implBeforeTcpConnect(FileDescriptor fdObj,
63
InetAddress address,
64
int port)
65
throws IOException;
66
}
67
68
/**
69
* For now, we load the SDP provider on Solaris. In the future this may
70
* be changed to use the ServiceLoader facility to allow the deployment of
71
* other providers.
72
*/
73
private static final Provider provider = new sun.net.sdp.SdpProvider();
74
75
/**
76
* Invoke prior to binding a TCP socket.
77
*/
78
public static void beforeTcpBind(FileDescriptor fdObj,
79
InetAddress address,
80
int port)
81
throws IOException
82
{
83
provider.implBeforeTcpBind(fdObj, address, port);
84
}
85
86
/**
87
* Invoke prior to connecting an unbound TCP socket.
88
*/
89
public static void beforeTcpConnect(FileDescriptor fdObj,
90
InetAddress address,
91
int port)
92
throws IOException
93
{
94
provider.implBeforeTcpConnect(fdObj, address, port);
95
}
96
}
97
98