Package io.netty.channel.kqueue
Class BsdSocket
- java.lang.Object
-
- io.netty.channel.unix.FileDescriptor
-
- io.netty.channel.unix.Socket
-
- io.netty.channel.kqueue.BsdSocket
-
final class BsdSocket extends Socket
A socket which provides access BSD native methods.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
APPLE_SND_LOW_AT_MAX
(package private) static int
BSD_SND_LOW_AT_MAX
private static int
FREEBSD_SND_LOW_AT_MAX
private static int
UNSPECIFIED_SOURCE_INTERFACE
The `endpoints` structure passed to `connectx(2)` has an optional "source interface" field, which is the index of the network interface to use.-
Fields inherited from class io.netty.channel.unix.Socket
ipv6, UDS_SUN_PATH_SIZE
-
-
Constructor Summary
Constructors Constructor Description BsdSocket(int fd)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static int
connectx(int socketFd, int sourceInterface, boolean sourceIPv6, byte[] sourceAddress, int sourceScopeId, int sourcePort, boolean destinationIPv6, byte[] destinationAddress, int destinationScopeId, int destinationPort, int flags, long iovAddress, int iovCount, int iovDataLength)
(package private) int
connectx(java.net.InetSocketAddress source, java.net.InetSocketAddress destination, IovArray data, boolean tcpFastOpen)
Establish a connection to the given destination address, and send the given data to it.(package private) AcceptFilter
getAcceptFilter()
private static java.lang.String[]
getAcceptFilter(int fd)
(package private) PeerCredentials
getPeerCredentials()
private static PeerCredentials
getPeerCredentials(int fd)
(package private) int
getSndLowAt()
private static int
getSndLowAt(int fd)
private static int
getTcpNoPush(int fd)
boolean
isTcpFastOpen()
private static int
isTcpFastOpen(int fd)
(package private) boolean
isTcpNoPush()
static BsdSocket
newSocketDgram()
static BsdSocket
newSocketDgram(InternetProtocolFamily protocol)
static BsdSocket
newSocketDomain()
static BsdSocket
newSocketDomainDgram()
static BsdSocket
newSocketStream()
static BsdSocket
newSocketStream(InternetProtocolFamily protocol)
private static long
sendFile(int socketFd, DefaultFileRegion src, long baseOffset, long offset, long length)
(package private) long
sendFile(DefaultFileRegion src, long baseOffset, long offset, long length)
private static void
setAcceptFilter(int fd, java.lang.String filterName, java.lang.String filterArgs)
(package private) void
setAcceptFilter(AcceptFilter acceptFilter)
(package private) void
setSndLowAt(int lowAt)
private static void
setSndLowAt(int fd, int lowAt)
void
setTcpFastOpen(boolean enableTcpFastOpen)
private static void
setTcpFastOpen(int fd, int enableFastOpen)
(package private) void
setTcpNoPush(boolean tcpNoPush)
private static void
setTcpNoPush(int fd, int tcpNoPush)
-
Methods inherited from class io.netty.channel.unix.Socket
accept, bind, connect, disconnect, finishConnect, getIntOpt, getRawOpt, getReceiveBufferSize, getSendBufferSize, getSoError, getSoLinger, getTrafficClass, initialize, isBroadcast, isInputShutdown, isIPv6Preferred, isKeepAlive, isOutputShutdown, isReuseAddress, isReusePort, isShutdown, isTcpNoDelay, listen, localAddress, localDomainSocketAddress, newSocketDgram0, newSocketDgram0, newSocketDgram0, newSocketDomain0, newSocketDomainDgram0, newSocketStream0, newSocketStream0, newSocketStream0, recv, recvAddress, recvFd, recvFrom, recvFromAddress, recvFromAddressDomainSocket, recvFromDomainSocket, remoteAddress, remoteDomainSocketAddress, send, sendAddress, sendFd, sendTo, sendTo, sendToAddress, sendToAddress, sendToAddressDomainSocket, sendToAddresses, sendToAddresses, sendToAddressesDomainSocket, sendToDomainSocket, setBroadcast, setIntOpt, setKeepAlive, setRawOpt, setReceiveBufferSize, setReuseAddress, setReusePort, setSendBufferSize, setSoLinger, setTcpNoDelay, setTrafficClass, shouldUseIpv6, shutdown, shutdown, toString, useIpv6
-
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
-
APPLE_SND_LOW_AT_MAX
private static final int APPLE_SND_LOW_AT_MAX
- See Also:
- Constant Field Values
-
FREEBSD_SND_LOW_AT_MAX
private static final int FREEBSD_SND_LOW_AT_MAX
- See Also:
- Constant Field Values
-
BSD_SND_LOW_AT_MAX
static final int BSD_SND_LOW_AT_MAX
-
UNSPECIFIED_SOURCE_INTERFACE
private static final int UNSPECIFIED_SOURCE_INTERFACE
The `endpoints` structure passed to `connectx(2)` has an optional "source interface" field, which is the index of the network interface to use. According to `if_nametoindex(3)`, the value 0 is used when no interface is specified.- See Also:
- Constant Field Values
-
-
Method Detail
-
setAcceptFilter
void setAcceptFilter(AcceptFilter acceptFilter) throws java.io.IOException
- Throws:
java.io.IOException
-
setTcpNoPush
void setTcpNoPush(boolean tcpNoPush) throws java.io.IOException
- Throws:
java.io.IOException
-
setSndLowAt
void setSndLowAt(int lowAt) throws java.io.IOException
- Throws:
java.io.IOException
-
setTcpFastOpen
public void setTcpFastOpen(boolean enableTcpFastOpen) throws java.io.IOException
- Throws:
java.io.IOException
-
isTcpNoPush
boolean isTcpNoPush() throws java.io.IOException
- Throws:
java.io.IOException
-
getSndLowAt
int getSndLowAt() throws java.io.IOException
- Throws:
java.io.IOException
-
getAcceptFilter
AcceptFilter getAcceptFilter() throws java.io.IOException
- Throws:
java.io.IOException
-
isTcpFastOpen
public boolean isTcpFastOpen() throws java.io.IOException
- Throws:
java.io.IOException
-
getPeerCredentials
PeerCredentials getPeerCredentials() throws java.io.IOException
- Throws:
java.io.IOException
-
sendFile
long sendFile(DefaultFileRegion src, long baseOffset, long offset, long length) throws java.io.IOException
- Throws:
java.io.IOException
-
connectx
int connectx(java.net.InetSocketAddress source, java.net.InetSocketAddress destination, IovArray data, boolean tcpFastOpen) throws java.io.IOException
Establish a connection to the given destination address, and send the given data to it. Note: This method relies on theconnectx(2)
system call, which is MacOS specific.- Parameters:
source
- the source address we are connecting from.destination
- the destination address we are connecting to.data
- the data to copy to the kernel-side socket buffer.tcpFastOpen
- iftrue
, set the flags needed to enable TCP FastOpen connecting.- Returns:
- The number of bytes copied to the kernel-side socket buffer, or the number of bytes sent to the destination. This number is negative if connecting is left in an in-progress state, or positive if the connection was immediately established.
- Throws:
java.io.IOException
- if an IO error occurs, if thedata
is too big to send in one go, or if the system call is not supported on your platform.
-
newSocketStream
public static BsdSocket newSocketStream()
-
newSocketStream
public static BsdSocket newSocketStream(InternetProtocolFamily protocol)
-
newSocketDgram
public static BsdSocket newSocketDgram()
-
newSocketDgram
public static BsdSocket newSocketDgram(InternetProtocolFamily protocol)
-
newSocketDomain
public static BsdSocket newSocketDomain()
-
newSocketDomainDgram
public static BsdSocket newSocketDomainDgram()
-
sendFile
private static long sendFile(int socketFd, DefaultFileRegion src, long baseOffset, long offset, long length) throws java.io.IOException
- Throws:
java.io.IOException
-
connectx
private static int connectx(int socketFd, int sourceInterface, boolean sourceIPv6, byte[] sourceAddress, int sourceScopeId, int sourcePort, boolean destinationIPv6, byte[] destinationAddress, int destinationScopeId, int destinationPort, int flags, long iovAddress, int iovCount, int iovDataLength)
- Returns:
- If successful, zero or positive number of bytes transfered, otherwise negative errno.
-
getAcceptFilter
private static java.lang.String[] getAcceptFilter(int fd) throws java.io.IOException
- Throws:
java.io.IOException
-
getTcpNoPush
private static int getTcpNoPush(int fd) throws java.io.IOException
- Throws:
java.io.IOException
-
getSndLowAt
private static int getSndLowAt(int fd) throws java.io.IOException
- Throws:
java.io.IOException
-
isTcpFastOpen
private static int isTcpFastOpen(int fd) throws java.io.IOException
- Throws:
java.io.IOException
-
getPeerCredentials
private static PeerCredentials getPeerCredentials(int fd) throws java.io.IOException
- Throws:
java.io.IOException
-
setAcceptFilter
private static void setAcceptFilter(int fd, java.lang.String filterName, java.lang.String filterArgs) throws java.io.IOException
- Throws:
java.io.IOException
-
setTcpNoPush
private static void setTcpNoPush(int fd, int tcpNoPush) throws java.io.IOException
- Throws:
java.io.IOException
-
setSndLowAt
private static void setSndLowAt(int fd, int lowAt) throws java.io.IOException
- Throws:
java.io.IOException
-
setTcpFastOpen
private static void setTcpFastOpen(int fd, int enableFastOpen) throws java.io.IOException
- Throws:
java.io.IOException
-
-