34 /** |
34 /** |
35 * Allows different platforms to call different native methods |
35 * Allows different platforms to call different native methods |
36 * for read and write operations. |
36 * for read and write operations. |
37 */ |
37 */ |
38 |
38 |
39 class SocketDispatcher extends NativeDispatcher { |
39 public class SocketDispatcher extends NativeDispatcher { |
40 private static final JavaIOFileDescriptorAccess fdAccess = |
40 private static final JavaIOFileDescriptorAccess fdAccess = |
41 SharedSecrets.getJavaIOFileDescriptorAccess(); |
41 SharedSecrets.getJavaIOFileDescriptorAccess(); |
42 |
42 |
43 SocketDispatcher() { } |
43 public SocketDispatcher() { } |
44 |
44 |
45 int read(FileDescriptor fd, long address, int len) throws IOException { |
45 public int read(FileDescriptor fd, long address, int len) throws IOException { |
46 return read0(fd, address, len); |
46 return read0(fd, address, len); |
47 } |
47 } |
48 |
48 |
49 long readv(FileDescriptor fd, long address, int len) throws IOException { |
49 long readv(FileDescriptor fd, long address, int len) throws IOException { |
50 return readv0(fd, address, len); |
50 return readv0(fd, address, len); |
51 } |
51 } |
52 |
52 |
53 int write(FileDescriptor fd, long address, int len) throws IOException { |
53 public int write(FileDescriptor fd, long address, int len) throws IOException { |
54 return write0(fd, address, len); |
54 return write0(fd, address, len); |
55 } |
55 } |
56 |
56 |
57 long writev(FileDescriptor fd, long address, int len) throws IOException { |
57 long writev(FileDescriptor fd, long address, int len) throws IOException { |
58 return writev0(fd, address, len); |
58 return writev0(fd, address, len); |
59 } |
59 } |
60 |
60 |
61 void preClose(FileDescriptor fd) throws IOException { |
61 public void preClose(FileDescriptor fd) throws IOException { |
62 throw new UnsupportedOperationException(); |
62 throw new UnsupportedOperationException(); |
63 } |
63 } |
64 |
64 |
65 void close(FileDescriptor fd) throws IOException { |
65 public void close(FileDescriptor fd) throws IOException { |
66 invalidateAndClose(fd); |
66 invalidateAndClose(fd); |
67 } |
67 } |
68 |
68 |
69 static void invalidateAndClose(FileDescriptor fd) throws IOException { |
69 static void invalidateAndClose(FileDescriptor fd) throws IOException { |
70 assert fd.valid(); |
70 assert fd.valid(); |