Class BsdSocket
java.lang.Object
io.netty.channel.unix.FileDescriptor
io.netty.channel.unix.Socket
io.netty.channel.kqueue.BsdSocket
A socket which provides access BSD native methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int(package private) static final intprivate static final intprivate static final intThe `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 Socket
ipv6, UDS_SUN_PATH_SIZE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static intconnectx(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) intconnectx(InetSocketAddress source, InetSocketAddress destination, IovArray data, boolean tcpFastOpen) Establish a connection to the given destination address, and send the given data to it.(package private) AcceptFilterprivate static String[]getAcceptFilter(int fd) (package private) PeerCredentialsprivate static PeerCredentialsgetPeerCredentials(int fd) (package private) intprivate static intgetSndLowAt(int fd) private static intgetTcpNoPush(int fd) booleanprivate static intisTcpFastOpen(int fd) (package private) booleanstatic BsdSocketstatic BsdSocketnewSocketDgram(InternetProtocolFamily protocol) static BsdSocketstatic BsdSocketstatic BsdSocketstatic BsdSocketnewSocketStream(InternetProtocolFamily protocol) private static longsendFile(int socketFd, DefaultFileRegion src, long baseOffset, long offset, long length) (package private) longsendFile(DefaultFileRegion src, long baseOffset, long offset, long length) private static voidsetAcceptFilter(int fd, String filterName, String filterArgs) (package private) voidsetAcceptFilter(AcceptFilter acceptFilter) (package private) voidsetSndLowAt(int lowAt) private static voidsetSndLowAt(int fd, int lowAt) voidsetTcpFastOpen(boolean enableTcpFastOpen) private static voidsetTcpFastOpen(int fd, int enableFastOpen) (package private) voidsetTcpNoPush(boolean tcpNoPush) private static voidsetTcpNoPush(int fd, int tcpNoPush) Methods inherited from class 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, useIpv6Methods inherited from class FileDescriptor
close, equals, from, from, hashCode, intValue, isOpen, markClosed, pipe, read, readAddress, write, writeAddress, writev, writevAddresses
-
Field Details
-
APPLE_SND_LOW_AT_MAX
private static final int APPLE_SND_LOW_AT_MAX- See Also:
-
FREEBSD_SND_LOW_AT_MAX
private static final int FREEBSD_SND_LOW_AT_MAX- See Also:
-
BSD_SND_LOW_AT_MAX
static final int BSD_SND_LOW_AT_MAX -
UNSPECIFIED_SOURCE_INTERFACE
private static final int UNSPECIFIED_SOURCE_INTERFACEThe `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:
-
-
Constructor Details
-
BsdSocket
BsdSocket(int fd)
-
-
Method Details
-
setAcceptFilter
- Throws:
IOException
-
setTcpNoPush
- Throws:
IOException
-
setSndLowAt
- Throws:
IOException
-
setTcpFastOpen
- Throws:
IOException
-
isTcpNoPush
- Throws:
IOException
-
getSndLowAt
- Throws:
IOException
-
getAcceptFilter
- Throws:
IOException
-
isTcpFastOpen
- Throws:
IOException
-
getPeerCredentials
- Throws:
IOException
-
sendFile
- Throws:
IOException
-
connectx
int connectx(InetSocketAddress source, InetSocketAddress destination, IovArray data, boolean tcpFastOpen) throws 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:
IOException- if an IO error occurs, if thedatais too big to send in one go, or if the system call is not supported on your platform.
-
newSocketStream
-
newSocketStream
-
newSocketDgram
-
newSocketDgram
-
newSocketDomain
-
newSocketDomainDgram
-
sendFile
private static long sendFile(int socketFd, DefaultFileRegion src, long baseOffset, long offset, long length) throws IOException - Throws:
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
- Throws:
IOException
-
getTcpNoPush
- Throws:
IOException
-
getSndLowAt
- Throws:
IOException
-
isTcpFastOpen
- Throws:
IOException
-
getPeerCredentials
- Throws:
IOException
-
setAcceptFilter
private static void setAcceptFilter(int fd, String filterName, String filterArgs) throws IOException - Throws:
IOException
-
setTcpNoPush
- Throws:
IOException
-
setSndLowAt
- Throws:
IOException
-
setTcpFastOpen
- Throws:
IOException
-