Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.base/unix/classes/sun/nio/ch/SocketDispatcher.java
41137 views
1
/*
2
* Copyright (c) 2000, 2019, 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.nio.ch;
27
28
import java.io.FileDescriptor;
29
import java.io.IOException;
30
31
/**
32
* Allows different platforms to call different native methods
33
* for read and write operations.
34
*/
35
36
class SocketDispatcher extends NativeDispatcher {
37
SocketDispatcher() { }
38
39
/**
40
* Reads up to len bytes from a socket with special handling for "connection
41
* reset".
42
*
43
* @throws sun.net.ConnectionResetException if connection reset is detected
44
* @throws IOException if another I/O error occurs
45
*/
46
int read(FileDescriptor fd, long address, int len) throws IOException {
47
return read0(fd, address, len);
48
}
49
50
/**
51
* Scattering read from a socket into len buffers with special handling for
52
* "connection reset".
53
*
54
* @throws sun.net.ConnectionResetException if connection reset is detected
55
* @throws IOException if another I/O error occurs
56
*/
57
long readv(FileDescriptor fd, long address, int len) throws IOException {
58
return readv0(fd, address, len);
59
}
60
61
int write(FileDescriptor fd, long address, int len) throws IOException {
62
return FileDispatcherImpl.write0(fd, address, len);
63
}
64
65
long writev(FileDescriptor fd, long address, int len) throws IOException {
66
return FileDispatcherImpl.writev0(fd, address, len);
67
}
68
69
void close(FileDescriptor fd) throws IOException {
70
FileDispatcherImpl.close0(fd);
71
}
72
73
void preClose(FileDescriptor fd) throws IOException {
74
FileDispatcherImpl.preClose0(fd);
75
}
76
77
// -- Native methods --
78
79
private static native int read0(FileDescriptor fd, long address, int len)
80
throws IOException;
81
82
private static native long readv0(FileDescriptor fd, long address, int len)
83
throws IOException;
84
85
static {
86
IOUtil.load();
87
}
88
}
89
90