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
AChannelimplementation that uses a native unix socket
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description UnixSocketChannelbind(java.net.SocketAddress local)booleanconnect(java.net.SocketAddress remote)booleanconnect(UnixSocketAddress remote)static UnixSocketChannelcreate()booleanfinishConnect()static UnixSocketChannelfromFD(int fd)Create a UnixSocketChannel to wrap an existing file descriptor (presumably itself a UNIX socket).java.net.SocketAddressgetLocalAddress()UnixSocketAddressgetLocalSocketAddress()<T> TgetOption(java.net.SocketOption<T> name)java.net.SocketAddressgetRemoteAddress()UnixSocketAddressgetRemoteSocketAddress()booleanisConnected()booleanisConnectionPending()static UnixSocketChannelopen()static UnixSocketChannelopen(UnixSocketAddress remote)static UnixSocketChannel[]pair()intread(java.nio.ByteBuffer dst)<T> java.nio.channels.SocketChannelsetOption(java.net.SocketOption<T> name, T value)UnixSocketsocket()java.util.Set<java.net.SocketOption<?>>supportedOptions()intwrite(java.nio.ByteBuffer src)longwrite(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:
isConnectedin classjava.nio.channels.SocketChannel
-
isConnectionPending
public boolean isConnectionPending()
- Specified by:
isConnectionPendingin classjava.nio.channels.SocketChannel
-
finishConnect
public boolean finishConnect() throws java.io.IOException- Specified by:
finishConnectin 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:
connectin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
socket
public UnixSocket socket()
- Specified by:
socketin classjava.nio.channels.SocketChannel
-
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException- Specified by:
writein interfacejava.nio.channels.GatheringByteChannel- Overrides:
writein classAbstractNativeSocketChannel- Throws:
java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException- Specified by:
readin interfacejava.nio.channels.ReadableByteChannel- Overrides:
readin classAbstractNativeSocketChannel- Throws:
java.io.IOException
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException- Specified by:
writein interfacejava.nio.channels.WritableByteChannel- Overrides:
writein classAbstractNativeSocketChannel- Throws:
java.io.IOException
-
getRemoteAddress
public java.net.SocketAddress getRemoteAddress() throws java.io.IOException- Specified by:
getRemoteAddressin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
getLocalAddress
public java.net.SocketAddress getLocalAddress() throws java.io.IOException- Specified by:
getLocalAddressin interfacejava.nio.channels.NetworkChannel- Specified by:
getLocalAddressin 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:
setOptionin interfacejava.nio.channels.NetworkChannel- Specified by:
setOptionin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
bind
public UnixSocketChannel bind(java.net.SocketAddress local) throws java.io.IOException
- Specified by:
bindin interfacejava.nio.channels.NetworkChannel- Specified by:
bindin classjava.nio.channels.SocketChannel- Throws:
java.io.IOException
-
-