public class FileDescriptorByteChannel
extends java.lang.Object
implements java.nio.channels.ByteChannel
| Modifier and Type | Field and Description |
|---|---|
private int |
fd |
private boolean |
isOpen |
private jnr.posix.LibC |
libc |
| Constructor and Description |
|---|
FileDescriptorByteChannel(Ruby runtime,
int fd)
Creates a new FileDescriptorByteChannel.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the Channel.
|
boolean |
isOpen()
Tests if the ByteChannel is open.
|
private static jnr.posix.LibC |
libc(Ruby runtime) |
int |
read(java.nio.ByteBuffer dst)
Reads data from the native unix file descriptor.
|
int |
write(java.nio.ByteBuffer src)
Writes data to the native unix file descriptor.
|
private final jnr.posix.LibC libc
private final int fd
private volatile boolean isOpen
public FileDescriptorByteChannel(Ruby runtime, int fd)
fd - The native unix fd to read/write.private static jnr.posix.LibC libc(Ruby runtime)
public int read(java.nio.ByteBuffer dst)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChanneldst - The destination ByteBuffer to place read bytes in.java.io.IOException - If an error occurred during reading.public int write(java.nio.ByteBuffer src)
throws java.io.IOException
write in interface java.nio.channels.WritableByteChannelsrc - The source ByteBuffer to write to the file descriptor.java.io.IOException - If an error occurred during writing.public boolean isOpen()
isOpen in interface java.nio.channels.Channelpublic void close()
throws java.io.IOException
This closes the underlying native file descriptor.
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channeljava.io.IOException