Package jnr.unixsocket
Class UnixSocketChannel
- java.lang.Object
-
- java.nio.channels.spi.AbstractInterruptibleChannel
-
- java.nio.channels.SelectableChannel
-
- java.nio.channels.spi.AbstractSelectableChannel
-
- java.nio.channels.SocketChannel
-
- jnr.unixsocket.impl.AbstractNativeSocketChannel
-
- jnr.unixsocket.UnixSocketChannel
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.nio.channels.ByteChannel
,java.nio.channels.Channel
,java.nio.channels.GatheringByteChannel
,java.nio.channels.InterruptibleChannel
,java.nio.channels.NetworkChannel
,java.nio.channels.ReadableByteChannel
,java.nio.channels.ScatteringByteChannel
,java.nio.channels.WritableByteChannel
,jnr.enxio.channels.NativeSelectableChannel
public class UnixSocketChannel extends AbstractNativeSocketChannel
AChannel
implementation that uses a native unix socket
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UnixSocketChannel
bind(java.net.SocketAddress local)
boolean
connect(java.net.SocketAddress remote)
boolean
connect(UnixSocketAddress remote)
static UnixSocketChannel
create()
boolean
finishConnect()
static UnixSocketChannel
fromFD(int fd)
Create a UnixSocketChannel to wrap an existing file descriptor (presumably itself a UNIX socket).java.net.SocketAddress
getLocalAddress()
UnixSocketAddress
getLocalSocketAddress()
<T> T
getOption(java.net.SocketOption<T> name)
java.net.SocketAddress
getRemoteAddress()
UnixSocketAddress
getRemoteSocketAddress()
boolean
isConnected()
boolean
isConnectionPending()
static UnixSocketChannel
open()
static UnixSocketChannel
open(UnixSocketAddress remote)
static UnixSocketChannel[]
pair()
int
read(java.nio.ByteBuffer dst)
<T> java.nio.channels.SocketChannel
setOption(java.net.SocketOption<T> name, T value)
UnixSocket
socket()
java.util.Set<java.net.SocketOption<?>>
supportedOptions()
int
write(java.nio.ByteBuffer src)
long
write(java.nio.ByteBuffer[] srcs, int offset, int length)
-
Methods inherited from class jnr.unixsocket.impl.AbstractNativeSocketChannel
getFD, implCloseSelectableChannel, implConfigureBlocking, read, setFD, shutdownInput, shutdownOutput
-
Methods inherited from class java.nio.channels.spi.AbstractSelectableChannel
blockingLock, configureBlocking, implCloseChannel, isBlocking, isRegistered, keyFor, provider, register
-
Methods inherited from class java.nio.channels.spi.AbstractInterruptibleChannel
begin, close, end, isOpen
-
-
-
-
Method Detail
-
open
public static final UnixSocketChannel open() throws java.io.IOException
- Throws:
java.io.IOException
-
open
public static final UnixSocketChannel open(UnixSocketAddress remote) throws java.io.IOException
- Throws:
java.io.IOException
-
create
public static final UnixSocketChannel create() throws java.io.IOException
- Throws:
java.io.IOException
-
pair
public static final UnixSocketChannel[] pair() throws java.io.IOException
- Throws:
java.io.IOException
-
fromFD
public static final UnixSocketChannel fromFD(int fd)
Create a UnixSocketChannel to wrap an existing file descriptor (presumably itself a UNIX socket).- Parameters:
fd
- the file descriptor to wrap- Returns:
- the new UnixSocketChannel instance
-
connect
public boolean connect(UnixSocketAddress remote) throws java.io.IOException
- Throws:
java.io.IOException
-
isConnected
public boolean isConnected()
- Specified by:
isConnected
in classjava.nio.channels.SocketChannel
-
isConnectionPending
public boolean isConnectionPending()
- Specified by:
isConnectionPending
in classjava.nio.channels.SocketChannel
-
finishConnect
public boolean finishConnect() throws java.io.IOException
- Specified by:
finishConnect
in classjava.nio.channels.SocketChannel
- Throws:
java.io.IOException
-
getRemoteSocketAddress
public final UnixSocketAddress getRemoteSocketAddress()
-
getLocalSocketAddress
public final UnixSocketAddress getLocalSocketAddress()
-
connect
public boolean connect(java.net.SocketAddress remote) throws java.io.IOException
- Specified by:
connect
in classjava.nio.channels.SocketChannel
- Throws:
java.io.IOException
-
socket
public UnixSocket socket()
- Specified by:
socket
in classjava.nio.channels.SocketChannel
-
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
- Specified by:
write
in interfacejava.nio.channels.GatheringByteChannel
- Overrides:
write
in classAbstractNativeSocketChannel
- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException
- Specified by:
read
in interfacejava.nio.channels.ReadableByteChannel
- Overrides:
read
in classAbstractNativeSocketChannel
- Throws:
java.io.IOException
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException
- Specified by:
write
in interfacejava.nio.channels.WritableByteChannel
- Overrides:
write
in classAbstractNativeSocketChannel
- Throws:
java.io.IOException
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress() throws java.io.IOException
- Specified by:
getRemoteAddress
in classjava.nio.channels.SocketChannel
- Throws:
java.io.IOException
-
getLocalAddress
public java.net.SocketAddress getLocalAddress() throws java.io.IOException
- Specified by:
getLocalAddress
in interfacejava.nio.channels.NetworkChannel
- Specified by:
getLocalAddress
in classjava.nio.channels.SocketChannel
- Throws:
java.io.IOException
-
supportedOptions
public final java.util.Set<java.net.SocketOption<?>> supportedOptions()
-
getOption
public <T> T getOption(java.net.SocketOption<T> name) throws java.io.IOException
- Throws:
java.io.IOException
-
setOption
public <T> java.nio.channels.SocketChannel setOption(java.net.SocketOption<T> name, T value) throws java.io.IOException
- Specified by:
setOption
in interfacejava.nio.channels.NetworkChannel
- Specified by:
setOption
in classjava.nio.channels.SocketChannel
- Throws:
java.io.IOException
-
bind
public UnixSocketChannel bind(java.net.SocketAddress local) throws java.io.IOException
- Specified by:
bind
in interfacejava.nio.channels.NetworkChannel
- Specified by:
bind
in classjava.nio.channels.SocketChannel
- Throws:
java.io.IOException
-
-