Package io.netty.channel.unix
Class Socket
- java.lang.Object
-
- io.netty.channel.unix.FileDescriptor
-
- io.netty.channel.unix.Socket
-
- Direct Known Subclasses:
LinuxSocket
public class Socket extends FileDescriptor
Provides a JNI bridge to native socket operations. Internal usage only!
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
ipv6
static int
UDS_SUN_PATH_SIZE
Deprecated.
-
Constructor Summary
Constructors Constructor Description Socket(int fd)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
accept(byte[] addr)
void
bind(java.net.SocketAddress socketAddress)
boolean
connect(java.net.SocketAddress socketAddress)
void
disconnect()
boolean
finishConnect()
int
getIntOpt(int level, int optname)
void
getRawOpt(int level, int optname, java.nio.ByteBuffer out)
int
getReceiveBufferSize()
int
getSendBufferSize()
int
getSoError()
int
getSoLinger()
int
getTrafficClass()
static void
initialize()
boolean
isBroadcast()
boolean
isInputShutdown()
static boolean
isIPv6Preferred()
boolean
isKeepAlive()
boolean
isOutputShutdown()
boolean
isReuseAddress()
boolean
isReusePort()
boolean
isShutdown()
boolean
isTcpNoDelay()
void
listen(int backlog)
java.net.InetSocketAddress
localAddress()
DomainSocketAddress
localDomainSocketAddress()
static Socket
newSocketDgram()
protected static int
newSocketDgram0()
protected static int
newSocketDgram0(boolean ipv6)
protected static int
newSocketDgram0(InternetProtocolFamily family)
Deprecated.protected static int
newSocketDgram0(SocketProtocolFamily family)
static Socket
newSocketDomain()
protected static int
newSocketDomain0()
static Socket
newSocketDomainDgram()
protected static int
newSocketDomainDgram0()
static Socket
newSocketStream()
protected static int
newSocketStream0()
protected static int
newSocketStream0(boolean ipv6)
protected static int
newSocketStream0(InternetProtocolFamily protocol)
Deprecated.protected static int
newSocketStream0(SocketProtocolFamily protocol)
int
recv(java.nio.ByteBuffer buf, int pos, int limit)
int
recvAddress(long address, int pos, int limit)
int
recvFd()
DatagramSocketAddress
recvFrom(java.nio.ByteBuffer buf, int pos, int limit)
DatagramSocketAddress
recvFromAddress(long memoryAddress, int pos, int limit)
DomainDatagramSocketAddress
recvFromAddressDomainSocket(long memoryAddress, int pos, int limit)
DomainDatagramSocketAddress
recvFromDomainSocket(java.nio.ByteBuffer buf, int pos, int limit)
java.net.InetSocketAddress
remoteAddress()
DomainSocketAddress
remoteDomainSocketAddress()
int
send(java.nio.ByteBuffer buf, int pos, int limit)
int
sendAddress(long address, int pos, int limit)
int
sendFd(int fdToSend)
int
sendTo(java.nio.ByteBuffer buf, int pos, int limit, java.net.InetAddress addr, int port)
int
sendTo(java.nio.ByteBuffer buf, int pos, int limit, java.net.InetAddress addr, int port, boolean fastOpen)
int
sendToAddress(long memoryAddress, int pos, int limit, java.net.InetAddress addr, int port)
int
sendToAddress(long memoryAddress, int pos, int limit, java.net.InetAddress addr, int port, boolean fastOpen)
int
sendToAddressDomainSocket(long memoryAddress, int pos, int limit, byte[] path)
int
sendToAddresses(long memoryAddress, int length, java.net.InetAddress addr, int port)
int
sendToAddresses(long memoryAddress, int length, java.net.InetAddress addr, int port, boolean fastOpen)
int
sendToAddressesDomainSocket(long memoryAddress, int length, byte[] path)
int
sendToDomainSocket(java.nio.ByteBuffer buf, int pos, int limit, byte[] path)
void
setBroadcast(boolean broadcast)
void
setIntOpt(int level, int optname, int optvalue)
void
setKeepAlive(boolean keepAlive)
void
setRawOpt(int level, int optname, java.nio.ByteBuffer optvalue)
void
setReceiveBufferSize(int receiveBufferSize)
void
setReuseAddress(boolean reuseAddress)
void
setReusePort(boolean reusePort)
void
setSendBufferSize(int sendBufferSize)
void
setSoLinger(int soLinger)
void
setTcpNoDelay(boolean tcpNoDelay)
void
setTrafficClass(int trafficClass)
static boolean
shouldUseIpv6(InternetProtocolFamily family)
Deprecated.static boolean
shouldUseIpv6(SocketProtocolFamily family)
void
shutdown()
void
shutdown(boolean read, boolean write)
java.lang.String
toString()
protected static boolean
useIpv6(Socket socket, java.net.InetAddress address)
Returnstrue
if the given socket and address combination should use IPv6 internally,false
otherwise.-
Methods inherited from class io.netty.channel.unix.FileDescriptor
close, equals, from, from, hashCode, intValue, isOpen, markClosed, pipe, read, readAddress, write, writeAddress, writev, writevAddresses
-
-
-
-
Field Detail
-
UDS_SUN_PATH_SIZE
@Deprecated public static final int UDS_SUN_PATH_SIZE
Deprecated.- See Also:
- Constant Field Values
-
ipv6
protected final boolean ipv6
-
-
Method Detail
-
useIpv6
protected static boolean useIpv6(Socket socket, java.net.InetAddress address)
Returnstrue
if the given socket and address combination should use IPv6 internally,false
otherwise.
-
shutdown
public final void shutdown() throws java.io.IOException
- Throws:
java.io.IOException
-
shutdown
public final void shutdown(boolean read, boolean write) throws java.io.IOException
- Throws:
java.io.IOException
-
isShutdown
public final boolean isShutdown()
-
isInputShutdown
public final boolean isInputShutdown()
-
isOutputShutdown
public final boolean isOutputShutdown()
-
sendTo
public final int sendTo(java.nio.ByteBuffer buf, int pos, int limit, java.net.InetAddress addr, int port) throws java.io.IOException
- Throws:
java.io.IOException
-
sendTo
public final int sendTo(java.nio.ByteBuffer buf, int pos, int limit, java.net.InetAddress addr, int port, boolean fastOpen) throws java.io.IOException
- Throws:
java.io.IOException
-
sendToDomainSocket
public final int sendToDomainSocket(java.nio.ByteBuffer buf, int pos, int limit, byte[] path) throws java.io.IOException
- Throws:
java.io.IOException
-
sendToAddress
public final int sendToAddress(long memoryAddress, int pos, int limit, java.net.InetAddress addr, int port) throws java.io.IOException
- Throws:
java.io.IOException
-
sendToAddress
public final int sendToAddress(long memoryAddress, int pos, int limit, java.net.InetAddress addr, int port, boolean fastOpen) throws java.io.IOException
- Throws:
java.io.IOException
-
sendToAddressDomainSocket
public final int sendToAddressDomainSocket(long memoryAddress, int pos, int limit, byte[] path) throws java.io.IOException
- Throws:
java.io.IOException
-
sendToAddresses
public final int sendToAddresses(long memoryAddress, int length, java.net.InetAddress addr, int port) throws java.io.IOException
- Throws:
java.io.IOException
-
sendToAddresses
public final int sendToAddresses(long memoryAddress, int length, java.net.InetAddress addr, int port, boolean fastOpen) throws java.io.IOException
- Throws:
java.io.IOException
-
sendToAddressesDomainSocket
public final int sendToAddressesDomainSocket(long memoryAddress, int length, byte[] path) throws java.io.IOException
- Throws:
java.io.IOException
-
recvFrom
public final DatagramSocketAddress recvFrom(java.nio.ByteBuffer buf, int pos, int limit) throws java.io.IOException
- Throws:
java.io.IOException
-
recvFromAddress
public final DatagramSocketAddress recvFromAddress(long memoryAddress, int pos, int limit) throws java.io.IOException
- Throws:
java.io.IOException
-
recvFromDomainSocket
public final DomainDatagramSocketAddress recvFromDomainSocket(java.nio.ByteBuffer buf, int pos, int limit) throws java.io.IOException
- Throws:
java.io.IOException
-
recvFromAddressDomainSocket
public final DomainDatagramSocketAddress recvFromAddressDomainSocket(long memoryAddress, int pos, int limit) throws java.io.IOException
- Throws:
java.io.IOException
-
recv
public int recv(java.nio.ByteBuffer buf, int pos, int limit) throws java.io.IOException
- Throws:
java.io.IOException
-
recvAddress
public int recvAddress(long address, int pos, int limit) throws java.io.IOException
- Throws:
java.io.IOException
-
send
public int send(java.nio.ByteBuffer buf, int pos, int limit) throws java.io.IOException
- Throws:
java.io.IOException
-
sendAddress
public int sendAddress(long address, int pos, int limit) throws java.io.IOException
- Throws:
java.io.IOException
-
recvFd
public final int recvFd() throws java.io.IOException
- Throws:
java.io.IOException
-
sendFd
public final int sendFd(int fdToSend) throws java.io.IOException
- Throws:
java.io.IOException
-
connect
public final boolean connect(java.net.SocketAddress socketAddress) throws java.io.IOException
- Throws:
java.io.IOException
-
finishConnect
public final boolean finishConnect() throws java.io.IOException
- Throws:
java.io.IOException
-
disconnect
public final void disconnect() throws java.io.IOException
- Throws:
java.io.IOException
-
bind
public final void bind(java.net.SocketAddress socketAddress) throws java.io.IOException
- Throws:
java.io.IOException
-
listen
public final void listen(int backlog) throws java.io.IOException
- Throws:
java.io.IOException
-
accept
public final int accept(byte[] addr) throws java.io.IOException
- Throws:
java.io.IOException
-
remoteAddress
public final java.net.InetSocketAddress remoteAddress()
-
remoteDomainSocketAddress
public final DomainSocketAddress remoteDomainSocketAddress()
-
localAddress
public final java.net.InetSocketAddress localAddress()
-
localDomainSocketAddress
public final DomainSocketAddress localDomainSocketAddress()
-
getReceiveBufferSize
public final int getReceiveBufferSize() throws java.io.IOException
- Throws:
java.io.IOException
-
getSendBufferSize
public final int getSendBufferSize() throws java.io.IOException
- Throws:
java.io.IOException
-
isKeepAlive
public final boolean isKeepAlive() throws java.io.IOException
- Throws:
java.io.IOException
-
isTcpNoDelay
public final boolean isTcpNoDelay() throws java.io.IOException
- Throws:
java.io.IOException
-
isReuseAddress
public final boolean isReuseAddress() throws java.io.IOException
- Throws:
java.io.IOException
-
isReusePort
public final boolean isReusePort() throws java.io.IOException
- Throws:
java.io.IOException
-
isBroadcast
public final boolean isBroadcast() throws java.io.IOException
- Throws:
java.io.IOException
-
getSoLinger
public final int getSoLinger() throws java.io.IOException
- Throws:
java.io.IOException
-
getSoError
public final int getSoError() throws java.io.IOException
- Throws:
java.io.IOException
-
getTrafficClass
public final int getTrafficClass() throws java.io.IOException
- Throws:
java.io.IOException
-
setKeepAlive
public final void setKeepAlive(boolean keepAlive) throws java.io.IOException
- Throws:
java.io.IOException
-
setReceiveBufferSize
public final void setReceiveBufferSize(int receiveBufferSize) throws java.io.IOException
- Throws:
java.io.IOException
-
setSendBufferSize
public final void setSendBufferSize(int sendBufferSize) throws java.io.IOException
- Throws:
java.io.IOException
-
setTcpNoDelay
public final void setTcpNoDelay(boolean tcpNoDelay) throws java.io.IOException
- Throws:
java.io.IOException
-
setSoLinger
public final void setSoLinger(int soLinger) throws java.io.IOException
- Throws:
java.io.IOException
-
setReuseAddress
public final void setReuseAddress(boolean reuseAddress) throws java.io.IOException
- Throws:
java.io.IOException
-
setReusePort
public final void setReusePort(boolean reusePort) throws java.io.IOException
- Throws:
java.io.IOException
-
setBroadcast
public final void setBroadcast(boolean broadcast) throws java.io.IOException
- Throws:
java.io.IOException
-
setTrafficClass
public final void setTrafficClass(int trafficClass) throws java.io.IOException
- Throws:
java.io.IOException
-
setIntOpt
public void setIntOpt(int level, int optname, int optvalue) throws java.io.IOException
- Throws:
java.io.IOException
-
setRawOpt
public void setRawOpt(int level, int optname, java.nio.ByteBuffer optvalue) throws java.io.IOException
- Throws:
java.io.IOException
-
getIntOpt
public int getIntOpt(int level, int optname) throws java.io.IOException
- Throws:
java.io.IOException
-
getRawOpt
public void getRawOpt(int level, int optname, java.nio.ByteBuffer out) throws java.io.IOException
- Throws:
java.io.IOException
-
isIPv6Preferred
public static boolean isIPv6Preferred()
-
shouldUseIpv6
@Deprecated public static boolean shouldUseIpv6(InternetProtocolFamily family)
Deprecated.
-
shouldUseIpv6
public static boolean shouldUseIpv6(SocketProtocolFamily family)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classFileDescriptor
-
newSocketStream
public static Socket newSocketStream()
-
newSocketDgram
public static Socket newSocketDgram()
-
newSocketDomain
public static Socket newSocketDomain()
-
newSocketDomainDgram
public static Socket newSocketDomainDgram()
-
initialize
public static void initialize()
-
newSocketStream0
protected static int newSocketStream0()
-
newSocketStream0
@Deprecated protected static int newSocketStream0(InternetProtocolFamily protocol)
Deprecated.- Parameters:
protocol
-- Returns:
-
newSocketStream0
protected static int newSocketStream0(SocketProtocolFamily protocol)
-
newSocketStream0
protected static int newSocketStream0(boolean ipv6)
-
newSocketDgram0
protected static int newSocketDgram0()
-
newSocketDgram0
@Deprecated protected static int newSocketDgram0(InternetProtocolFamily family)
Deprecated.
-
newSocketDgram0
protected static int newSocketDgram0(SocketProtocolFamily family)
-
newSocketDgram0
protected static int newSocketDgram0(boolean ipv6)
-
newSocketDomain0
protected static int newSocketDomain0()
-
newSocketDomainDgram0
protected static int newSocketDomainDgram0()
-
-