- 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 booleanipv6static intUDS_SUN_PATH_SIZEDeprecated.
-
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 intaccept(byte[] addr)voidbind(SocketAddress socketAddress)booleanconnect(SocketAddress socketAddress)voiddisconnect()booleanfinishConnect()intgetIntOpt(int level, int optname)voidgetRawOpt(int level, int optname, ByteBuffer out)intgetReceiveBufferSize()intgetSendBufferSize()intgetSoError()intgetSoLinger()intgetTrafficClass()static voidinitialize()booleanisBroadcast()booleanisInputShutdown()static booleanisIPv6Preferred()booleanisKeepAlive()booleanisOutputShutdown()booleanisReuseAddress()booleanisReusePort()booleanisShutdown()booleanisTcpNoDelay()voidlisten(int backlog)InetSocketAddresslocalAddress()static SocketnewSocketDgram()protected static intnewSocketDgram0()protected static intnewSocketDgram0(boolean ipv6)protected static intnewSocketDgram0(ProtocolFamily family)static SocketnewSocketDomain()protected static intnewSocketDomain0()static SocketnewSocketDomainDgram()protected static intnewSocketDomainDgram0()static SocketnewSocketStream()protected static intnewSocketStream0()protected static intnewSocketStream0(boolean ipv6)protected static intnewSocketStream0(ProtocolFamily protocol)SocketProtocolFamilyprotocolFamily()intrecvFd()DatagramSocketAddressrecvFrom(ByteBuffer buf, int pos, int limit)DatagramSocketAddressrecvFromAddress(long memoryAddress, int pos, int limit)DomainDatagramSocketAddressrecvFromAddressDomainSocket(long memoryAddress, int pos, int limit)DomainDatagramSocketAddressrecvFromDomainSocket(ByteBuffer buf, int pos, int limit)InetSocketAddressremoteAddress()intsendFd(int fdToSend)intsendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port)intsendTo(ByteBuffer buf, int pos, int limit, InetAddress addr, int port, boolean fastOpen)intsendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port)intsendToAddress(long memoryAddress, int pos, int limit, InetAddress addr, int port, boolean fastOpen)intsendToAddressDomainSocket(long memoryAddress, int pos, int limit, byte[] path)intsendToAddresses(long memoryAddress, int length, InetAddress addr, int port)intsendToAddresses(long memoryAddress, int length, InetAddress addr, int port, boolean fastOpen)intsendToAddressesDomainSocket(long memoryAddress, int length, byte[] path)intsendToDomainSocket(ByteBuffer buf, int pos, int limit, byte[] path)voidsetBroadcast(boolean broadcast)voidsetIntOpt(int level, int optname, int optvalue)voidsetKeepAlive(boolean keepAlive)voidsetRawOpt(int level, int optname, ByteBuffer optvalue)voidsetReceiveBufferSize(int receiveBufferSize)voidsetReuseAddress(boolean reuseAddress)voidsetReusePort(boolean reusePort)voidsetSendBufferSize(int sendBufferSize)voidsetSoLinger(int soLinger)voidsetTcpNoDelay(boolean tcpNoDelay)voidsetTrafficClass(int trafficClass)static booleanshouldUseIpv6(ProtocolFamily family)voidshutdown()voidshutdown(boolean read, boolean write)StringtoString()protected static booleanuseIpv6(Socket socket, InetAddress address)Returnstrueif the given socket and address combination should use IPv6 internally,falseotherwise.-
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)
Returnstrueif the given socket and address combination should use IPv6 internally,falseotherwise.
-
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:
toStringin 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()
-
-