- java.lang.Object
-
- io.netty5.channel.unix.FileDescriptor
-
- io.netty5.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, SocketProtocolFamily protocolFamily)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
accept(byte[] addr)
void
bind(SocketAddress socketAddress)
boolean
connect(SocketAddress socketAddress)
void
disconnect()
boolean
finishConnect()
int
getIntOpt(int level, int optname)
void
getRawOpt(int level, int optname, 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)
InetSocketAddress
localAddress()
static Socket
newSocketDgram()
protected static int
newSocketDgram0()
protected static int
newSocketDgram0(boolean ipv6)
protected static int
newSocketDgram0(ProtocolFamily 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(ProtocolFamily protocol)
SocketProtocolFamily
protocolFamily()
int
recvFd()
DatagramSocketAddress
recvFrom(ByteBuffer buf, int pos, int limit)
DatagramSocketAddress
recvFromAddress(long memoryAddress, int pos, int limit)
DomainDatagramSocketAddress
recvFromAddressDomainSocket(long memoryAddress, int pos, int limit)
DomainDatagramSocketAddress
recvFromDomainSocket(ByteBuffer buf, int pos, int limit)
InetSocketAddress
remoteAddress()
int
sendFd(int fdToSend)
int
sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port)
int
sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port, boolean fastOpen)
int
sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port)
int
sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port, boolean fastOpen)
int
sendToAddressDomainSocket(long memoryAddress, int pos, int limit, byte[] path)
int
sendToAddresses(long memoryAddress, int length, InetAddress addr, int port)
int
sendToAddresses(long memoryAddress, int length, InetAddress addr, int port, boolean fastOpen)
int
sendToAddressesDomainSocket(long memoryAddress, int length, byte[] path)
int
sendToDomainSocket(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, 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(ProtocolFamily family)
void
shutdown()
void
shutdown(boolean read, boolean write)
String
toString()
protected static boolean
useIpv6(Socket socket, InetAddress address)
Returnstrue
if the given socket and address combination should use IPv6 internally,false
otherwise.-
Methods inherited from class io.netty5.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
-
-
Constructor Detail
-
Socket
public Socket(int fd, SocketProtocolFamily protocolFamily)
-
-
Method Detail
-
useIpv6
protected static boolean useIpv6(Socket socket, InetAddress address)
Returnstrue
if the given socket and address combination should use IPv6 internally,false
otherwise.
-
protocolFamily
public final SocketProtocolFamily protocolFamily()
-
shutdown
public final void shutdown() throws IOException
- Throws:
IOException
-
shutdown
public final void shutdown(boolean read, boolean write) throws IOException
- Throws:
IOException
-
isShutdown
public final boolean isShutdown()
-
isInputShutdown
public final boolean isInputShutdown()
-
isOutputShutdown
public final boolean isOutputShutdown()
-
sendTo
public final int sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port) throws IOException
- Throws:
IOException
-
sendTo
public final int sendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port, boolean fastOpen) throws IOException
- Throws:
IOException
-
sendToDomainSocket
public final int sendToDomainSocket(ByteBuffer buf, int pos, int limit, byte[] path) throws IOException
- Throws:
IOException
-
sendToAddress
public final int sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port) throws IOException
- Throws:
IOException
-
sendToAddress
public final int sendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port, boolean fastOpen) throws IOException
- Throws:
IOException
-
sendToAddressDomainSocket
public final int sendToAddressDomainSocket(long memoryAddress, int pos, int limit, byte[] path) throws IOException
- Throws:
IOException
-
sendToAddresses
public final int sendToAddresses(long memoryAddress, int length, InetAddress addr, int port) throws IOException
- Throws:
IOException
-
sendToAddresses
public final int sendToAddresses(long memoryAddress, int length, InetAddress addr, int port, boolean fastOpen) throws IOException
- Throws:
IOException
-
sendToAddressesDomainSocket
public final int sendToAddressesDomainSocket(long memoryAddress, int length, byte[] path) throws IOException
- Throws:
IOException
-
recvFrom
public final DatagramSocketAddress recvFrom(ByteBuffer buf, int pos, int limit) throws IOException
- Throws:
IOException
-
recvFromAddress
public final DatagramSocketAddress recvFromAddress(long memoryAddress, int pos, int limit) throws IOException
- Throws:
IOException
-
recvFromDomainSocket
public final DomainDatagramSocketAddress recvFromDomainSocket(ByteBuffer buf, int pos, int limit) throws IOException
- Throws:
IOException
-
recvFromAddressDomainSocket
public final DomainDatagramSocketAddress recvFromAddressDomainSocket(long memoryAddress, int pos, int limit) throws IOException
- Throws:
IOException
-
recvFd
public final int recvFd() throws IOException
- Throws:
IOException
-
sendFd
public final int sendFd(int fdToSend) throws IOException
- Throws:
IOException
-
connect
public final boolean connect(SocketAddress socketAddress) throws IOException
- Throws:
IOException
-
finishConnect
public final boolean finishConnect() throws IOException
- Throws:
IOException
-
disconnect
public final void disconnect() throws IOException
- Throws:
IOException
-
bind
public final void bind(SocketAddress socketAddress) throws IOException
- Throws:
IOException
-
listen
public final void listen(int backlog) throws IOException
- Throws:
IOException
-
accept
public final int accept(byte[] addr) throws IOException
- Throws:
IOException
-
remoteAddress
public final InetSocketAddress remoteAddress()
-
localAddress
public final InetSocketAddress localAddress()
-
getReceiveBufferSize
public final int getReceiveBufferSize() throws IOException
- Throws:
IOException
-
getSendBufferSize
public final int getSendBufferSize() throws IOException
- Throws:
IOException
-
isKeepAlive
public final boolean isKeepAlive() throws IOException
- Throws:
IOException
-
isTcpNoDelay
public final boolean isTcpNoDelay() throws IOException
- Throws:
IOException
-
isReuseAddress
public final boolean isReuseAddress() throws IOException
- Throws:
IOException
-
isReusePort
public final boolean isReusePort() throws IOException
- Throws:
IOException
-
isBroadcast
public final boolean isBroadcast() throws IOException
- Throws:
IOException
-
getSoLinger
public final int getSoLinger() throws IOException
- Throws:
IOException
-
getSoError
public final int getSoError() throws IOException
- Throws:
IOException
-
getTrafficClass
public final int getTrafficClass() throws IOException
- Throws:
IOException
-
setKeepAlive
public final void setKeepAlive(boolean keepAlive) throws IOException
- Throws:
IOException
-
setReceiveBufferSize
public final void setReceiveBufferSize(int receiveBufferSize) throws IOException
- Throws:
IOException
-
setSendBufferSize
public final void setSendBufferSize(int sendBufferSize) throws IOException
- Throws:
IOException
-
setTcpNoDelay
public final void setTcpNoDelay(boolean tcpNoDelay) throws IOException
- Throws:
IOException
-
setSoLinger
public final void setSoLinger(int soLinger) throws IOException
- Throws:
IOException
-
setReuseAddress
public final void setReuseAddress(boolean reuseAddress) throws IOException
- Throws:
IOException
-
setReusePort
public final void setReusePort(boolean reusePort) throws IOException
- Throws:
IOException
-
setBroadcast
public final void setBroadcast(boolean broadcast) throws IOException
- Throws:
IOException
-
setTrafficClass
public final void setTrafficClass(int trafficClass) throws IOException
- Throws:
IOException
-
setIntOpt
public void setIntOpt(int level, int optname, int optvalue) throws IOException
- Throws:
IOException
-
setRawOpt
public void setRawOpt(int level, int optname, ByteBuffer optvalue) throws IOException
- Throws:
IOException
-
getIntOpt
public int getIntOpt(int level, int optname) throws IOException
- Throws:
IOException
-
getRawOpt
public void getRawOpt(int level, int optname, ByteBuffer out) throws IOException
- Throws:
IOException
-
isIPv6Preferred
public static boolean isIPv6Preferred()
-
shouldUseIpv6
public static boolean shouldUseIpv6(ProtocolFamily family)
-
toString
public 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
protected static int newSocketStream0(ProtocolFamily protocol)
-
newSocketStream0
protected static int newSocketStream0(boolean ipv6)
-
newSocketDgram0
protected static int newSocketDgram0()
-
newSocketDgram0
protected static int newSocketDgram0(ProtocolFamily family)
-
newSocketDgram0
protected static int newSocketDgram0(boolean ipv6)
-
newSocketDomain0
protected static int newSocketDomain0()
-
newSocketDomainDgram0
protected static int newSocketDomainDgram0()
-
-