Package one.nio.net
Class NativeSocket
java.lang.Object
one.nio.net.Socket
one.nio.net.NativeSocket
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,ReadableByteChannel,WritableByteChannel
- Direct Known Subclasses:
NativeSslSocket
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long(package private) intprivate static final intprivate static final longFields inherited from class one.nio.net.Socket
AF_INET, AF_INET6, AF_UNIX, IPTOS_LOWDELAY, IPTOS_MINCOST, IPTOS_RELIABILITY, IPTOS_THROUGHPUT, MSG_DONTROUTE, MSG_DONTWAIT, MSG_MORE, MSG_OOB, MSG_PEEK, MSG_TRUNC, MSG_WAITALL, NO_PORT, SO_BROADCAST, SO_BSDCOMPAT, SO_DEBUG, SO_DONTROUTE, SO_ERROR, SO_KEEPALIVE, SO_LINGER, SO_NO_CHECK, SO_OOBINLINE, SO_PASSCRED, SO_PEERCRED, SO_PRIORITY, SO_RCVBUF, SO_RCVLOWAT, SO_RCVTIMEO, SO_REUSEADDR, SO_REUSEPORT, SO_SNDBUF, SO_SNDLOWAT, SO_SNDTIMEO, SO_TYPE, SOCK_DGRAM, SOCK_RAW, SOCK_RDM, SOCK_SEQPACKET, SOCK_STREAM, SOL_IP, SOL_IPV6, SOL_SOCKET, SOL_TCP, SOL_UDP, TCP_CONGESTION, TCP_CORK, TCP_DEFER_ACCEPT, TCP_INFO, TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL, TCP_LINGER2, TCP_MAXSEG, TCP_NODELAY, TCP_QUICKACK, TCP_SYNCNT, TCP_USER_TIMEOUT, TCP_WINDOW_CLAMP -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccept()(package private) final intaccept0(boolean nonblock) voidvoidbind(InetAddress address, int port, int backlog) (package private) final voidvoidclose()voidvoidconnect(InetAddress address, int port) (package private) final voidprivate byte[]getArray(ByteBuffer src) final booleanfinal booleanfinal InetSocketAddressfinal booleanfinal intprivate intgetOffset(ByteBuffer src) byte[]getOption(int level, int option) final intfinal InetSocketAddressfinal booleanfinal booleanfinal int<T> TgetSslOption(SslOption<T> option) final booleanfinal booleanfinal intfinal intgetTos()private static intinitNatives(boolean preferIPv4) final booleanfinal booleanisOpen()voidlisten(int backlog) intread(byte[] data, int offset, int count, int flags) intread(ByteBuffer dst) voidreadFully(byte[] data, int offset, int count) intreadRaw(long buf, int count, int flags) recv(ByteBuffer dst, int flags) (package private) final intrecvFrom0(byte[] data, int offset, int maxSize, int flags, AddressHolder holder) (package private) final intrecvFrom1(long buf, int maxSize, int flags, AddressHolder holder) int(package private) final intintsend(ByteBuffer data, int flags, String host, int port) intsend(ByteBuffer src, int flags, InetAddress address, int port) longsendFile(RandomAccessFile file, long offset, long count) (package private) longsendFile0(int sourceFD, long offset, long count) int(package private) final intsendMsg0(byte[] data, int cmsgType, int[] cmsgData, int flags) private intsendTo(ByteBuffer src, int flags, Object address, int port) (package private) final int(package private) final intfinal voidsetBlocking(boolean blocking) final voidsetDeferAccept(boolean deferAccept) final voidsetKeepAlive(boolean keepAlive) final voidsetNoDelay(boolean noDelay) final voidsetNotsentLowat(int lowat) booleansetOption(int level, int option, byte[] value) final voidsetRecvBuffer(int recvBuf) final voidsetReuseAddr(boolean reuseAddr, boolean reusePort) final voidsetSendBuffer(int sendBuf) final voidsetTcpFastOpen(boolean tcpFastOpen) final voidsetThinLinearTimeouts(boolean thinLto) final voidsetTimeout(int timeout) final voidsetTos(int tos) private static intsocket0(int domain, int type) sslWrap(SslContext context) (package private) static ObjecttoNativeAddr(String host, int port) intwrite(byte[] data, int offset, int count, int flags) intwrite(ByteBuffer src) voidwriteFully(byte[] data, int offset, int count) intwriteRaw(long buf, int count, int flags) Methods inherited from class one.nio.net.Socket
bindInet, bindUnix, connectInet, connectUnix, create, createClientSocket, createClientSocket, createDatagramSocket, createServerSocket, createUnixSocket, fromFD, handshake, read, write
-
Field Details
-
INET_FAMILY
private static final int INET_FAMILY -
ARRAY_FIELD
private static final long ARRAY_FIELD -
OFFSET_FIELD
private static final long OFFSET_FIELD -
fd
int fd
-
-
Constructor Details
-
NativeSocket
NativeSocket(int domain, int type) throws IOException - Throws:
IOException
-
NativeSocket
NativeSocket(int fd)
-
-
Method Details
-
isOpen
public final boolean isOpen() -
accept
- Specified by:
acceptin classSocket- Throws:
IOException
-
acceptNonBlocking
- Overrides:
acceptNonBlockingin classSocket- Throws:
IOException
-
getLocalAddress
- Specified by:
getLocalAddressin classSocket
-
getRemoteAddress
- Specified by:
getRemoteAddressin classSocket
-
sslWrap
- Specified by:
sslWrapin classSocket- Throws:
IOException
-
sslUnwrap
-
getSslContext
- Specified by:
getSslContextin classSocket
-
getSslOption
- Specified by:
getSslOptionin classSocket
-
connect
- Specified by:
connectin classSocket- Throws:
IOException
-
connect
- Overrides:
connectin classSocket- Throws:
IOException
-
bind
- Specified by:
bindin classSocket- Throws:
IOException
-
bind
- Overrides:
bindin classSocket- Throws:
IOException
-
listen
- Specified by:
listenin classSocket- Throws:
IOException
-
close
public void close() -
writeRaw
- Specified by:
writeRawin classSocket- Throws:
IOException
-
send
- Specified by:
sendin classSocket- Throws:
IOException
-
send
- Overrides:
sendin classSocket- Throws:
IOException
-
sendTo
- Throws:
IOException
-
getArray
- Throws:
IllegalAccessException
-
getOffset
- Throws:
IllegalAccessException
-
write
- Specified by:
writein classSocket- Throws:
IOException
-
writeFully
- Specified by:
writeFullyin classSocket- Throws:
IOException
-
readRaw
- Specified by:
readRawin classSocket- Throws:
IOException
-
read
- Specified by:
readin classSocket- Throws:
IOException
-
recv
- Specified by:
recvin classSocket- Throws:
IOException
-
readFully
- Specified by:
readFullyin classSocket- Throws:
IOException
-
sendFile
- Specified by:
sendFilein classSocket- Throws:
IOException
-
read
- Throws:
IOException
-
write
- Throws:
IOException
-
sendMsg
- Specified by:
sendMsgin classSocket- Throws:
IOException
-
recvMsg
- Specified by:
recvMsgin classSocket- Throws:
IOException
-
setBlocking
public final void setBlocking(boolean blocking) - Specified by:
setBlockingin classSocket
-
isBlocking
public final boolean isBlocking()- Specified by:
isBlockingin classSocket
-
setTimeout
public final void setTimeout(int timeout) - Specified by:
setTimeoutin classSocket
-
getTimeout
public final int getTimeout()- Specified by:
getTimeoutin classSocket
-
setKeepAlive
public final void setKeepAlive(boolean keepAlive) - Specified by:
setKeepAlivein classSocket
-
getKeepAlive
public final boolean getKeepAlive()- Specified by:
getKeepAlivein classSocket
-
setNoDelay
public final void setNoDelay(boolean noDelay) - Specified by:
setNoDelayin classSocket
-
getNoDelay
public final boolean getNoDelay()- Specified by:
getNoDelayin classSocket
-
setTcpFastOpen
public final void setTcpFastOpen(boolean tcpFastOpen) - Specified by:
setTcpFastOpenin classSocket
-
getTcpFastOpen
public final boolean getTcpFastOpen()- Specified by:
getTcpFastOpenin classSocket
-
setDeferAccept
public final void setDeferAccept(boolean deferAccept) - Specified by:
setDeferAcceptin classSocket
-
getDeferAccept
public final boolean getDeferAccept()- Specified by:
getDeferAcceptin classSocket
-
setReuseAddr
public final void setReuseAddr(boolean reuseAddr, boolean reusePort) - Specified by:
setReuseAddrin classSocket
-
getReuseAddr
public final boolean getReuseAddr()- Specified by:
getReuseAddrin classSocket
-
getReusePort
public final boolean getReusePort()- Specified by:
getReusePortin classSocket
-
setRecvBuffer
public final void setRecvBuffer(int recvBuf) - Specified by:
setRecvBufferin classSocket
-
getRecvBuffer
public final int getRecvBuffer()- Specified by:
getRecvBufferin classSocket
-
setSendBuffer
public final void setSendBuffer(int sendBuf) - Specified by:
setSendBufferin classSocket
-
getSendBuffer
public final int getSendBuffer()- Specified by:
getSendBufferin classSocket
-
setTos
public final void setTos(int tos) -
getTos
public final int getTos() -
setNotsentLowat
public final void setNotsentLowat(int lowat) - Overrides:
setNotsentLowatin classSocket
-
getNotsentLowat
public final int getNotsentLowat()- Overrides:
getNotsentLowatin classSocket
-
setThinLinearTimeouts
public final void setThinLinearTimeouts(boolean thinLto) - Overrides:
setThinLinearTimeoutsin classSocket
-
getThinLinearTimeouts
public final boolean getThinLinearTimeouts()- Overrides:
getThinLinearTimeoutsin classSocket
-
getOption
public byte[] getOption(int level, int option) -
setOption
public boolean setOption(int level, int option, byte[] value) -
toNativeAddr
- Throws:
UnknownHostException
-
initNatives
private static int initNatives(boolean preferIPv4) -
socket0
- Throws:
IOException
-
connect0
- Throws:
IOException
-
bind0
- Throws:
IOException
-
accept0
- Throws:
IOException
-
sendFile0
- Throws:
IOException
-
sendTo0
final int sendTo0(byte[] data, int offset, int size, int flags, Object address, int port) throws IOException - Throws:
IOException
-
sendTo1
- Throws:
IOException
-
recvFrom0
final int recvFrom0(byte[] data, int offset, int maxSize, int flags, AddressHolder holder) throws IOException - Throws:
IOException
-
recvFrom1
- Throws:
IOException
-
sendMsg0
- Throws:
IOException
-
recvMsg0
- Throws:
IOException
-