Top Description Fields Constructors Methods
io.netty.channel.unix

public Class Socket

extends FileDescriptor
Class Inheritance
Imports
io.netty.channel.ChannelException, io.netty.channel.socket.InternetProtocolFamily, io.netty.util.CharsetUtil, .NetUtil, java.io.IOException, java.net.Inet6Address, .InetAddress, .InetSocketAddress, .PortUnreachableException, .SocketAddress, java.nio.ByteBuffer, java.nio.channels.ClosedChannelException

Provides a JNI bridge to native socket operations. Internal usage only!

Field Summary

Modifier and TypeField and Description
protected final boolean
private static volatile boolean
public static final int
UDS_SUN_PATH_SIZE

Deprecated
Inherited from io.netty.channel.unix.FileDescriptor:
fdstate

Constructor Summary

AccessConstructor and Description
public
Socket(int fd)

Method Summary

Modifier and TypeMethod and Description
public final int
accept(byte[] addr)

private static native int
accept(int fd, byte[] addr)

public final void
bind(SocketAddress socketAddress)

private static native int
bind(int fd, boolean ipv6, byte[] address, int scopeId, int port)

private static native int
bindDomainSocket(int fd, byte[] path)

public final boolean
connect(SocketAddress socketAddress)

private static native int
connect(int fd, boolean ipv6, byte[] address, int scopeId, int port)

private static native int
connectDomainSocket(int fd, byte[] path)

public final void
private static native int
disconnect(int fd, boolean ipv6)

public final boolean
private static native int
finishConnect(int fd)

public int
getIntOpt(int level, int optname)

private static native int
getIntOpt(int fd, int level, int optname)

public void
getRawOpt(int level, int optname, ByteBuffer out)

private static native void
getRawOptAddress(int fd, int level, int optname, long outMemoryAddress, int length)

private static native void
getRawOptArray(int fd, int level, int optname, byte[] out, int offset, int length)

public final int
private static native int
public final int
private static native int
public final int
private static native int
getSoError(int fd)

public final int
private static native int
getSoLinger(int fd)

public final int
private static native int
getTrafficClass(int fd, boolean ipv6)

public static void
public final boolean
private static native int
isBroadcast(int fd)

public final boolean
private static native boolean
isIPv6(int fd)

public static boolean
private static native boolean
isIPv6Preferred0(boolean ipv4Preferred)

public final boolean
private static native int
isKeepAlive(int fd)

public final boolean
public final boolean
private static native int
public final boolean
private static native int
isReusePort(int fd)

public final boolean
public final boolean
private static native int
isTcpNoDelay(int fd)

public final void
listen(int backlog)

private static native int
listen(int fd, int backlog)

public final InetSocketAddress
private static native byte[]
localAddress(int fd)

public final DomainSocketAddress
private static native byte[]
private static native int
public static Socket
protected static int
protected static int
protected static int
newSocketDgram0(boolean ipv6)

private static native int
newSocketDgramFd(boolean ipv6)

public static Socket
protected static int
public static Socket
protected static int
private static native int
private static native int
public static Socket
protected static int
protected static int
protected static int
newSocketStream0(boolean ipv6)

private static native int
newSocketStreamFd(boolean ipv6)

public int
recv(ByteBuffer buf, int pos, int limit)

private static native int
recv(int fd, ByteBuffer buf, int pos, int limit)

public int
recvAddress(long address, int pos, int limit)

private static native int
recvAddress(int fd, long address, int pos, int limit)

public final int
private static native int
recvFd(int fd)

public final DatagramSocketAddress
recvFrom(ByteBuffer buf, int pos, int limit)

private static native DatagramSocketAddress
recvFrom(int fd, ByteBuffer buf, int pos, int limit)

public final DatagramSocketAddress
recvFromAddress(long memoryAddress, int pos, int limit)

private static native DatagramSocketAddress
recvFromAddress(int fd, long memoryAddress, int pos, int limit)

public final DomainDatagramSocketAddress
recvFromAddressDomainSocket(long memoryAddress, int pos, int limit)

private static native DomainDatagramSocketAddress
recvFromAddressDomainSocket(int fd, long memoryAddress, int pos, int limit)

public final DomainDatagramSocketAddress
recvFromDomainSocket(ByteBuffer buf, int pos, int limit)

private static native DomainDatagramSocketAddress
recvFromDomainSocket(int fd, ByteBuffer buf, int pos, int limit)

public final InetSocketAddress
private static native byte[]
remoteAddress(int fd)

public final DomainSocketAddress
private static native byte[]
public int
send(ByteBuffer buf, int pos, int limit)

private static native int
send(int fd, ByteBuffer buf, int pos, int limit)

public int
sendAddress(long address, int pos, int limit)

private static native int
sendAddress(int fd, long address, int pos, int limit)

public final int
sendFd(int fdToSend)

private static native int
sendFd(int socketFd, int fd)

public final int
sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port)

public final int
sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port, boolean fastOpen)

private static native int
sendTo(int fd, boolean ipv6, ByteBuffer buf, int pos, int limit, byte[] address, int scopeId, int port, int flags)

public final int
sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port)

public final int
sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port, boolean fastOpen)

private static native int
sendToAddress(int fd, boolean ipv6, long memoryAddress, int pos, int limit, byte[] address, int scopeId, int port, int flags)

public final int
sendToAddressDomainSocket(long memoryAddress, int pos, int limit, byte[] path)

private static native int
sendToAddressDomainSocket(int fd, long memoryAddress, int pos, int limit, byte[] path)

public final int
sendToAddresses(long memoryAddress, int length, InetAddress addr, int port)

public final int
sendToAddresses(long memoryAddress, int length, InetAddress addr, int port, boolean fastOpen)

private static native int
sendToAddresses(int fd, boolean ipv6, long memoryAddress, int length, byte[] address, int scopeId, int port, int flags)

public final int
sendToAddressesDomainSocket(long memoryAddress, int length, byte[] path)

private static native int
sendToAddressesDomainSocket(int fd, long memoryAddress, int length, byte[] path)

public final int
sendToDomainSocket(ByteBuffer buf, int pos, int limit, byte[] path)

private static native int
sendToDomainSocket(int fd, ByteBuffer buf, int pos, int limit, byte[] path)

public final void
setBroadcast(boolean broadcast)

private static native void
setBroadcast(int fd, int broadcast)

public void
setIntOpt(int level, int optname, int optvalue)

private static native void
setIntOpt(int fd, int level, int optname, int optvalue)

public final void
setKeepAlive(boolean keepAlive)

private static native void
setKeepAlive(int fd, int keepAlive)

public void
setRawOpt(int level, int optname, ByteBuffer optvalue)

private static native void
setRawOptAddress(int fd, int level, int optname, long optvalueMemoryAddress, int length)

private static native void
setRawOptArray(int fd, int level, int optname, byte[] optvalue, int offset, int length)

public final void
setReceiveBufferSize(int receiveBufferSize)

private static native void
setReceiveBufferSize(int fd, int receiveBufferSize)

public final void
setReuseAddress(boolean reuseAddress)

private static native void
setReuseAddress(int fd, int reuseAddress)

public final void
setReusePort(boolean reusePort)

private static native void
setReusePort(int fd, int reuseAddress)

public final void
setSendBufferSize(int sendBufferSize)

private static native void
setSendBufferSize(int fd, int sendBufferSize)

public final void
setSoLinger(int soLinger)

private static native void
setSoLinger(int fd, int soLinger)

public final void
setTcpNoDelay(boolean tcpNoDelay)

private static native void
setTcpNoDelay(int fd, int tcpNoDelay)

public final void
setTrafficClass(int trafficClass)

private static native void
setTrafficClass(int fd, boolean ipv6, int trafficClass)

public static boolean
public final void
public final void
shutdown(boolean read, boolean write)

private static native int
shutdown(int fd, boolean read, boolean write)

public String
toString()

Overrides io.netty.channel.unix.FileDescriptor.toString.

Returns a string representation of the object.
private boolean
useIpv6(InetAddress address)

Returns true if we should use IPv6 internally, false otherwise.

protected static boolean
useIpv6(Socket socket, InetAddress address)

Returns true if the given socket and address combination should use IPv6 internally, false otherwise.

Inherited from io.netty.channel.unix.FileDescriptor:
casStatecloseequalsfromfromhashCodeinputShutdownintValueisClosedisInputShutdownisOpenisOutputShutdownmarkClosedoutputShutdownpipereadreadAddresswritewriteAddresswritevwritevAddresses

Field Detail

ipv6back to summary
protected final boolean ipv6
isIpv6Preferredback to summary
private static volatile boolean isIpv6Preferred
UDS_SUN_PATH_SIZEback to summary
public static final int UDS_SUN_PATH_SIZE

Deprecated

Annotations
@Deprecated

Constructor Detail

Socketback to summary
public Socket(int fd)

Method Detail

acceptback to summary
public final int accept(byte[] addr) throws IOException
acceptback to summary
private static native int accept(int fd, byte[] addr)
bindback to summary
public final void bind(SocketAddress socketAddress) throws IOException
bindback to summary
private static native int bind(int fd, boolean ipv6, byte[] address, int scopeId, int port)
bindDomainSocketback to summary
private static native int bindDomainSocket(int fd, byte[] path)
connectback to summary
public final boolean connect(SocketAddress socketAddress) throws IOException
connectback to summary
private static native int connect(int fd, boolean ipv6, byte[] address, int scopeId, int port)
connectDomainSocketback to summary
private static native int connectDomainSocket(int fd, byte[] path)
disconnectback to summary
public final void disconnect() throws IOException
disconnectback to summary
private static native int disconnect(int fd, boolean ipv6)
finishConnectback to summary
public final boolean finishConnect() throws IOException
finishConnectback to summary
private static native int finishConnect(int fd)
getIntOptback to summary
public int getIntOpt(int level, int optname) throws IOException
getIntOptback to summary
private static native int getIntOpt(int fd, int level, int optname) throws IOException
getRawOptback to summary
public void getRawOpt(int level, int optname, ByteBuffer out) throws IOException
getRawOptAddressback to summary
private static native void getRawOptAddress(int fd, int level, int optname, long outMemoryAddress, int length) throws IOException
getRawOptArrayback to summary
private static native void getRawOptArray(int fd, int level, int optname, byte[] out, int offset, int length) throws IOException
getReceiveBufferSizeback to summary
public final int getReceiveBufferSize() throws IOException
getReceiveBufferSizeback to summary
private static native int getReceiveBufferSize(int fd) throws IOException
getSendBufferSizeback to summary
public final int getSendBufferSize() throws IOException
getSendBufferSizeback to summary
private static native int getSendBufferSize(int fd) throws IOException
getSoErrorback to summary
public final int getSoError() throws IOException
getSoErrorback to summary
private static native int getSoError(int fd) throws IOException
getSoLingerback to summary
public final int getSoLinger() throws IOException
getSoLingerback to summary
private static native int getSoLinger(int fd) throws IOException
getTrafficClassback to summary
public final int getTrafficClass() throws IOException
getTrafficClassback to summary
private static native int getTrafficClass(int fd, boolean ipv6) throws IOException
initializeback to summary
public static void initialize()
isBroadcastback to summary
public final boolean isBroadcast() throws IOException
isBroadcastback to summary
private static native int isBroadcast(int fd) throws IOException
isInputShutdownback to summary
public final boolean isInputShutdown()
isIPv6back to summary
private static native boolean isIPv6(int fd)
isIPv6Preferredback to summary
public static boolean isIPv6Preferred()
isIPv6Preferred0back to summary
private static native boolean isIPv6Preferred0(boolean ipv4Preferred)
isKeepAliveback to summary
public final boolean isKeepAlive() throws IOException
isKeepAliveback to summary
private static native int isKeepAlive(int fd) throws IOException
isOutputShutdownback to summary
public final boolean isOutputShutdown()
isReuseAddressback to summary
public final boolean isReuseAddress() throws IOException
isReuseAddressback to summary
private static native int isReuseAddress(int fd) throws IOException
isReusePortback to summary
public final boolean isReusePort() throws IOException
isReusePortback to summary
private static native int isReusePort(int fd) throws IOException
isShutdownback to summary
public final boolean isShutdown()
isTcpNoDelayback to summary
public final boolean isTcpNoDelay() throws IOException
isTcpNoDelayback to summary
private static native int isTcpNoDelay(int fd) throws IOException
listenback to summary
public final void listen(int backlog) throws IOException
listenback to summary
private static native int listen(int fd, int backlog)
localAddressback to summary
public final InetSocketAddress localAddress()
localAddressback to summary
private static native byte[] localAddress(int fd)
localDomainSocketAddressback to summary
public final DomainSocketAddress localDomainSocketAddress()
localDomainSocketAddressback to summary
private static native byte[] localDomainSocketAddress(int fd)
msgFastopenback to summary
private static native int msgFastopen()
newSocketDgramback to summary
public static Socket newSocketDgram()
newSocketDgram0back to summary
protected static int newSocketDgram0()
newSocketDgram0back to summary
protected static int newSocketDgram0(InternetProtocolFamily family)
newSocketDgram0back to summary
protected static int newSocketDgram0(boolean ipv6)
newSocketDgramFdback to summary
private static native int newSocketDgramFd(boolean ipv6)
newSocketDomainback to summary
public static Socket newSocketDomain()
newSocketDomain0back to summary
protected static int newSocketDomain0()
newSocketDomainDgramback to summary
public static Socket newSocketDomainDgram()
newSocketDomainDgram0back to summary
protected static int newSocketDomainDgram0()
newSocketDomainDgramFdback to summary
private static native int newSocketDomainDgramFd()
newSocketDomainFdback to summary
private static native int newSocketDomainFd()
newSocketStreamback to summary
public static Socket newSocketStream()
newSocketStream0back to summary
protected static int newSocketStream0()
newSocketStream0back to summary
protected static int newSocketStream0(InternetProtocolFamily protocol)
newSocketStream0back to summary
protected static int newSocketStream0(boolean ipv6)
newSocketStreamFdback to summary
private static native int newSocketStreamFd(boolean ipv6)
recvback to summary
public int recv(ByteBuffer buf, int pos, int limit) throws IOException
recvback to summary
private static native int recv(int fd, ByteBuffer buf, int pos, int limit)
recvAddressback to summary
public int recvAddress(long address, int pos, int limit) throws IOException
recvAddressback to summary
private static native int recvAddress(int fd, long address, int pos, int limit)
recvFdback to summary
public final int recvFd() throws IOException
recvFdback to summary
private static native int recvFd(int fd)
recvFromback to summary
public final DatagramSocketAddress recvFrom(ByteBuffer buf, int pos, int limit) throws IOException
recvFromback to summary
private static native DatagramSocketAddress recvFrom(int fd, ByteBuffer buf, int pos, int limit) throws IOException
recvFromAddressback to summary
public final DatagramSocketAddress recvFromAddress(long memoryAddress, int pos, int limit) throws IOException
recvFromAddressback to summary
private static native DatagramSocketAddress recvFromAddress(int fd, long memoryAddress, int pos, int limit) throws IOException
recvFromAddressDomainSocketback to summary
public final DomainDatagramSocketAddress recvFromAddressDomainSocket(long memoryAddress, int pos, int limit) throws IOException
recvFromAddressDomainSocketback to summary
private static native DomainDatagramSocketAddress recvFromAddressDomainSocket(int fd, long memoryAddress, int pos, int limit) throws IOException
recvFromDomainSocketback to summary
public final DomainDatagramSocketAddress recvFromDomainSocket(ByteBuffer buf, int pos, int limit) throws IOException
recvFromDomainSocketback to summary
private static native DomainDatagramSocketAddress recvFromDomainSocket(int fd, ByteBuffer buf, int pos, int limit) throws IOException
remoteAddressback to summary
public final InetSocketAddress remoteAddress()
remoteAddressback to summary
private static native byte[] remoteAddress(int fd)
remoteDomainSocketAddressback to summary
public final DomainSocketAddress remoteDomainSocketAddress()
remoteDomainSocketAddressback to summary
private static native byte[] remoteDomainSocketAddress(int fd)
sendback to summary
public int send(ByteBuffer buf, int pos, int limit) throws IOException
sendback to summary
private static native int send(int fd, ByteBuffer buf, int pos, int limit)
sendAddressback to summary
public int sendAddress(long address, int pos, int limit) throws IOException
sendAddressback to summary
private static native int sendAddress(int fd, long address, int pos, int limit)
sendFdback to summary
public final int sendFd(int fdToSend) throws IOException
sendFdback to summary
private static native int sendFd(int socketFd, int fd)
sendToback to summary
public final int sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port) throws IOException
sendToback to summary
public final int sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port, boolean fastOpen) throws IOException
sendToback to summary
private static native int sendTo(int fd, boolean ipv6, ByteBuffer buf, int pos, int limit, byte[] address, int scopeId, int port, int flags)
sendToAddressback to summary
public final int sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port) throws IOException
sendToAddressback to summary
public final int sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port, boolean fastOpen) throws IOException
sendToAddressback to summary
private static native int sendToAddress(int fd, boolean ipv6, long memoryAddress, int pos, int limit, byte[] address, int scopeId, int port, int flags)
sendToAddressDomainSocketback to summary
public final int sendToAddressDomainSocket(long memoryAddress, int pos, int limit, byte[] path) throws IOException
sendToAddressDomainSocketback to summary
private static native int sendToAddressDomainSocket(int fd, long memoryAddress, int pos, int limit, byte[] path)
sendToAddressesback to summary
public final int sendToAddresses(long memoryAddress, int length, InetAddress addr, int port) throws IOException
sendToAddressesback to summary
public final int sendToAddresses(long memoryAddress, int length, InetAddress addr, int port, boolean fastOpen) throws IOException
sendToAddressesback to summary
private static native int sendToAddresses(int fd, boolean ipv6, long memoryAddress, int length, byte[] address, int scopeId, int port, int flags)
sendToAddressesDomainSocketback to summary
public final int sendToAddressesDomainSocket(long memoryAddress, int length, byte[] path) throws IOException
sendToAddressesDomainSocketback to summary
private static native int sendToAddressesDomainSocket(int fd, long memoryAddress, int length, byte[] path)
sendToDomainSocketback to summary
public final int sendToDomainSocket(ByteBuffer buf, int pos, int limit, byte[] path) throws IOException
sendToDomainSocketback to summary
private static native int sendToDomainSocket(int fd, ByteBuffer buf, int pos, int limit, byte[] path)
setBroadcastback to summary
public final void setBroadcast(boolean broadcast) throws IOException
setBroadcastback to summary
private static native void setBroadcast(int fd, int broadcast) throws IOException
setIntOptback to summary
public void setIntOpt(int level, int optname, int optvalue) throws IOException
setIntOptback to summary
private static native void setIntOpt(int fd, int level, int optname, int optvalue) throws IOException
setKeepAliveback to summary
public final void setKeepAlive(boolean keepAlive) throws IOException
setKeepAliveback to summary
private static native void setKeepAlive(int fd, int keepAlive) throws IOException
setRawOptback to summary
public void setRawOpt(int level, int optname, ByteBuffer optvalue) throws IOException
setRawOptAddressback to summary
private static native void setRawOptAddress(int fd, int level, int optname, long optvalueMemoryAddress, int length) throws IOException
setRawOptArrayback to summary
private static native void setRawOptArray(int fd, int level, int optname, byte[] optvalue, int offset, int length) throws IOException
setReceiveBufferSizeback to summary
public final void setReceiveBufferSize(int receiveBufferSize) throws IOException
setReceiveBufferSizeback to summary
private static native void setReceiveBufferSize(int fd, int receiveBufferSize) throws IOException
setReuseAddressback to summary
public final void setReuseAddress(boolean reuseAddress) throws IOException
setReuseAddressback to summary
private static native void setReuseAddress(int fd, int reuseAddress) throws IOException
setReusePortback to summary
public final void setReusePort(boolean reusePort) throws IOException
setReusePortback to summary
private static native void setReusePort(int fd, int reuseAddress) throws IOException
setSendBufferSizeback to summary
public final void setSendBufferSize(int sendBufferSize) throws IOException
setSendBufferSizeback to summary
private static native void setSendBufferSize(int fd, int sendBufferSize) throws IOException
setSoLingerback to summary
public final void setSoLinger(int soLinger) throws IOException
setSoLingerback to summary
private static native void setSoLinger(int fd, int soLinger) throws IOException
setTcpNoDelayback to summary
public final void setTcpNoDelay(boolean tcpNoDelay) throws IOException
setTcpNoDelayback to summary
private static native void setTcpNoDelay(int fd, int tcpNoDelay) throws IOException
setTrafficClassback to summary
public final void setTrafficClass(int trafficClass) throws IOException
setTrafficClassback to summary
private static native void setTrafficClass(int fd, boolean ipv6, int trafficClass) throws IOException
shouldUseIpv6back to summary
public static boolean shouldUseIpv6(InternetProtocolFamily family)
shutdownback to summary
public final void shutdown() throws IOException
shutdownback to summary
public final void shutdown(boolean read, boolean write) throws IOException
shutdownback to summary
private static native int shutdown(int fd, boolean read, boolean write)
toStringback to summary
public String toString()

Overrides io.netty.channel.unix.FileDescriptor.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
useIpv6back to summary
private boolean useIpv6(InetAddress address)

Returns true if we should use IPv6 internally, false otherwise.

useIpv6back to summary
protected static boolean useIpv6(Socket socket, InetAddress address)

Returns true if the given socket and address combination should use IPv6 internally, false otherwise.