Package io.netty.channel.unix
Class FileDescriptor
- java.lang.Object
-
- io.netty.channel.unix.FileDescriptor
-
- Direct Known Subclasses:
Socket
public class FileDescriptor extends java.lang.ObjectNativeFileDescriptorimplementation which allows to wrap anintand provide aFileDescriptorfor it.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) intfd(package private) intstateBit map = [Output Shutdown | Input Shutdown | Closed]private static intSTATE_ALL_MASKprivate static intSTATE_CLOSED_MASKprivate static intSTATE_INPUT_SHUTDOWN_MASKprivate static intSTATE_OUTPUT_SHUTDOWN_MASKprivate static java.util.concurrent.atomic.AtomicIntegerFieldUpdater<FileDescriptor>stateUpdater
-
Constructor Summary
Constructors Constructor Description FileDescriptor(int fd)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) booleancasState(int expected, int update)voidclose()Close the file descriptor.private static intclose(int fd)booleanequals(java.lang.Object o)static FileDescriptorfrom(java.io.File file)Open a newFileDescriptorfor the givenFile.static FileDescriptorfrom(java.lang.String path)Open a newFileDescriptorfor the given path.inthashCode()(package private) static intinputShutdown(int state)intintValue()Return the int value of the filedescriptor.(package private) static booleanisClosed(int state)(package private) static booleanisInputShutdown(int state)booleanisOpen()Returnstrueif the file descriptor is open.(package private) static booleanisOutputShutdown(int state)protected booleanmarkClosed()private static longnewPipe()private static intopen(java.lang.String path)(package private) static intoutputShutdown(int state)static FileDescriptor[]pipe()private static intread(int fd, java.nio.ByteBuffer buf, int pos, int limit)intread(java.nio.ByteBuffer buf, int pos, int limit)private static intreadAddress(int fd, long address, int pos, int limit)intreadAddress(long address, int pos, int limit)java.lang.StringtoString()private static intwrite(int fd, java.nio.ByteBuffer buf, int pos, int limit)intwrite(java.nio.ByteBuffer buf, int pos, int limit)private static intwriteAddress(int fd, long address, int pos, int limit)intwriteAddress(long address, int pos, int limit)private static longwritev(int fd, java.nio.ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite)longwritev(java.nio.ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite)private static longwritevAddresses(int fd, long memoryAddress, int length)longwritevAddresses(long memoryAddress, int length)
-
-
-
Field Detail
-
stateUpdater
private static final java.util.concurrent.atomic.AtomicIntegerFieldUpdater<FileDescriptor> stateUpdater
-
STATE_CLOSED_MASK
private static final int STATE_CLOSED_MASK
- See Also:
- Constant Field Values
-
STATE_INPUT_SHUTDOWN_MASK
private static final int STATE_INPUT_SHUTDOWN_MASK
- See Also:
- Constant Field Values
-
STATE_OUTPUT_SHUTDOWN_MASK
private static final int STATE_OUTPUT_SHUTDOWN_MASK
- See Also:
- Constant Field Values
-
STATE_ALL_MASK
private static final int STATE_ALL_MASK
- See Also:
- Constant Field Values
-
state
volatile int state
Bit map = [Output Shutdown | Input Shutdown | Closed]
-
fd
final int fd
-
-
Method Detail
-
intValue
public final int intValue()
Return the int value of the filedescriptor.
-
markClosed
protected boolean markClosed()
-
close
public void close() throws java.io.IOExceptionClose the file descriptor.- Throws:
java.io.IOException
-
isOpen
public boolean isOpen()
Returnstrueif the file descriptor is open.
-
write
public final int write(java.nio.ByteBuffer buf, int pos, int limit) throws java.io.IOException- Throws:
java.io.IOException
-
writeAddress
public final int writeAddress(long address, int pos, int limit) throws java.io.IOException- Throws:
java.io.IOException
-
writev
public final long writev(java.nio.ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite) throws java.io.IOException- Throws:
java.io.IOException
-
writevAddresses
public final long writevAddresses(long memoryAddress, int length) throws java.io.IOException- Throws:
java.io.IOException
-
read
public final int read(java.nio.ByteBuffer buf, int pos, int limit) throws java.io.IOException- Throws:
java.io.IOException
-
readAddress
public final int readAddress(long address, int pos, int limit) throws java.io.IOException- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
from
public static FileDescriptor from(java.lang.String path) throws java.io.IOException
Open a newFileDescriptorfor the given path.- Throws:
java.io.IOException
-
from
public static FileDescriptor from(java.io.File file) throws java.io.IOException
Open a newFileDescriptorfor the givenFile.- Throws:
java.io.IOException
-
pipe
public static FileDescriptor[] pipe() throws java.io.IOException
- Returns:
- [0] = read end, [1] = write end
- Throws:
java.io.IOException
-
casState
final boolean casState(int expected, int update)
-
isClosed
static boolean isClosed(int state)
-
isInputShutdown
static boolean isInputShutdown(int state)
-
isOutputShutdown
static boolean isOutputShutdown(int state)
-
inputShutdown
static int inputShutdown(int state)
-
outputShutdown
static int outputShutdown(int state)
-
open
private static int open(java.lang.String path)
-
close
private static int close(int fd)
-
write
private static int write(int fd, java.nio.ByteBuffer buf, int pos, int limit)
-
writeAddress
private static int writeAddress(int fd, long address, int pos, int limit)
-
writev
private static long writev(int fd, java.nio.ByteBuffer[] buffers, int offset, int length, long maxBytesToWrite)
-
writevAddresses
private static long writevAddresses(int fd, long memoryAddress, int length)
-
read
private static int read(int fd, java.nio.ByteBuffer buf, int pos, int limit)
-
readAddress
private static int readAddress(int fd, long address, int pos, int limit)
-
newPipe
private static long newPipe()
-
-