Top Description Inners Fields Constructors Methods
org.newsclub.net.unix

public abstract Class AFSocketImpl<A extends AFSocketAddress>

extends SocketImplShim
Class Inheritance
Known Direct Subclasses
org.newsclub.net.unix.AFUNIXSocketImpl, org.newsclub.net.unix.AFGenericSocketImpl
Annotations
@SuppressWarnings:PMD.CyclomaticComplexity, PMD.CouplingBetweenObjects, UnsafeFinalization
Type Parameters
<A>
The supported address type.
Static Imports
org.newsclub.net.unix.NativeUnixSocket.SHUT_RD, .NativeUnixSocket.SHUT_RD_WR, .NativeUnixSocket.SHUT_WR

junixsocket-based SocketImpl.
Author
Christian Kohlschütter

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
pack-priv static class
AFSocketImpl.AFSocketStreamCore

When the AFSocketImpl becomes unreachable (but not yet closed), we must ensure that the underlying socket and all related file descriptors are closed.

Field Summary

Modifier and TypeField and Description
private final AFAddressFamily<A>
pack-priv final AncillaryDataSupport
private final AtomicBoolean
private final AtomicBoolean
private volatile boolean
private volatile boolean
private final AtomicBoolean
private final AFSocketImpl.AFSocketStreamCore
private Boolean
private AFSocketImplExtensions<A>
private final AFInputStream
private final AFOutputStream
private boolean
private static final int
private int
private final AtomicInteger

Constructor Summary

AccessConstructor and Description
protected
AFSocketImpl(AFAddressFamily<@NonNull A>
The address family.
addressFamily
,
FileDescriptor
The socket's FileDescriptor.
fdObj
)

Creates a new AFSocketImpl instance.

Method Summary

Modifier and TypeMethod and Description
protected final void
accept(SocketImpl
the accepted connection.
socket
)

Implements abstract java.net.SocketImpl.accept.

Accepts a connection.

pack-priv final boolean
protected final int
available()

Implements abstract java.net.SocketImpl.available.

Returns the number of bytes that can be read from this socket without blocking.

pack-priv final void
bind(SocketAddress addr, int options)

protected final void
bind(InetAddress
an IP address that belongs to a local interface.
host
,
int
the port number.
port
)

Implements abstract java.net.SocketImpl.bind.

Binds this socket to the specified local IP address and port number.

private void
private static boolean
checkWriteInterruptedException(int bytesTransferred)

protected final void
close()

Implements abstract java.net.SocketImpl.close.

Closes this socket.

protected final void
connect(String
the name of the remote host.
host
,
int
the port number.
port
)

Implements abstract java.net.SocketImpl.connect.

Connects this socket to the specified port on the named host.

protected final void
connect(InetAddress
the IP address of the remote host.
address
,
int
the port number.
port
)

Implements abstract java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host.

protected final void
connect(SocketAddress
the Socket address of the remote host.
addr
,
int
the timeout value, in milliseconds, or zero for no timeout.
connectTimeout
)

Implements abstract java.net.SocketImpl.connect.

Connects this socket to the specified port number on the specified host.

pack-priv final boolean
connect0(SocketAddress addr, int connectTimeout)

protected final void
create(boolean
if true, create a stream socket; otherwise, create a datagram socket.
stream
)

Implements abstract java.net.SocketImpl.create.

Creates either a stream or a datagram socket.

pack-priv final void
pack-priv final void
private static int
private static int
pack-priv final AFAddressFamily<A>
pack-priv AncillaryDataSupport
pack-priv final int
pack-priv final AFSocketCore
pack-priv final FileDescriptor
protected final FileDescriptor
getFileDescriptor()

Overrides java.net.SocketImpl.getFileDescriptor.

Returns the value of this socket's fd field.

protected final synchronized AFSocketImplExtensions<A>

Returns:

The helper instance.
getImplExtensions
()

Returns the internal helper instance for address-specific extensions.

protected final InetAddress
getInetAddress()

Overrides java.net.SocketImpl.getInetAddress.

Returns the value of this socket's address field.

protected final AFInputStream
getInputStream()

Implements abstract java.net.SocketImpl.getInputStream.

Returns an input stream for this socket.

pack-priv final int
pack-priv final @Nullable A
public Object
getOption(int
an int identifying the option to fetch
optID
)

Implements java.net.SocketOptions.getOption.

Fetch the value of an option.

protected <T> T
getOption(SocketOption<T>
The socket option
name
)

Overrides java.net.SocketImpl.getOption.

Called to get a socket option.

private Object
getOption0(int optID)

pack-priv static final Object
getOptionDefault(FileDescriptor fdesc, int optID, AtomicInteger acceptTimeout, AFAddressFamily<?> af)

protected final Object

Returns:

The value.
getOptionLenient
(int
The option ID.
optID
)

Like getOption(int), but ignores exceptions for certain option IDs.

protected final AFOutputStream
getOutputStream()

Implements abstract java.net.SocketImpl.getOutputStream.

Returns an output stream for this socket.

pack-priv final int
pack-priv final @Nullable A
pack-priv final boolean
pack-priv boolean
pack-priv final boolean
protected final void
listen(int
the maximum length of the queue.
backlog
)

Implements abstract java.net.SocketImpl.listen.

Sets the maximum queue length for incoming connection indications (a request to connect) to the count argument.

protected final AFInputStream

Returns:

The new stream.
newInputStream
()

Creates a new InputStream for this socket.

protected final AFOutputStream

Returns:

The new stream.
newOutputStream
()

Creates a new OutputStream for this socket.

pack-priv final int
read(ByteBuffer dst, ByteBuffer socketAddressBuffer)

pack-priv final SocketAddress
pack-priv final int
protected final void
sendUrgentData(int
The byte of data to send
data
)

Implements abstract java.net.SocketImpl.sendUrgentData.

Send one byte of urgent data on the socket.

pack-priv final void
public void
setOption(int
identifies the option
optID
,
Object
the parameter of the socket option
value
)

Implements java.net.SocketOptions.setOption.

Enable/disable the option specified by optID.

protected <T> void
setOption(SocketOption<T>
The socket option
name
,
T
The value of the socket option. A value of null may be valid for some options.
value
)

Overrides java.net.SocketImpl.setOption.

Called to set a socket option.

private void
setOption0(int optID, Object value)

pack-priv static final void
setOptionDefault(FileDescriptor fdesc, int optID, Object value, AtomicInteger acceptTimeout)

protected final void
setOptionLenient(int
The option ID.
optID
,
Object
The value.
value
)

Like setOption(int, Object), but ignores exceptions for certain option IDs.

pack-priv final void
protected final void
shutdown()

Shuts down both input and output at once.

protected final void
shutdownInput()

Overrides java.net.SocketImpl.shutdownInput.

Places the input stream for this socket at "end of stream".

protected final void
shutdownOutput()

Overrides java.net.SocketImpl.shutdownOutput.

Disables the output stream for this socket.

protected Set<SocketOption<?>>
supportedOptions()

Overrides java.net.SocketImpl.supportedOptions.

Returns a set of SocketOptions supported by this impl and by this impl's socket (Socket or ServerSocket)

protected final boolean
supportsUrgentData()

Overrides java.net.SocketImpl.supportsUrgentData.

Returns whether or not this SocketImpl supports sending urgent data.

public final String
toString()

Overrides java.net.SocketImpl.toString.

Returns the address and port of this socket as a String.

pack-priv final void
updatePorts(int local, int remote)

pack-priv final int