Package one.nio.net
Class NativeSocket
- java.lang.Object
-
- one.nio.net.Socket
-
- one.nio.net.NativeSocket
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.ByteChannel,java.nio.channels.Channel,java.nio.channels.ReadableByteChannel,java.nio.channels.WritableByteChannel
- Direct Known Subclasses:
NativeSslSocket
class NativeSocket extends Socket
-
-
Field Summary
Fields Modifier and Type Field Description private static longARRAY_FIELD(package private) intfdprivate static intINET_FAMILYprivate static longOFFSET_FIELD-
Fields 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 Constructor Description NativeSocket(int fd)NativeSocket(int domain, int type)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description NativeSocketaccept()(package private) intaccept0(boolean nonblock)NativeSocketacceptNonBlocking()voidbind(java.lang.String host, int port, int backlog)voidbind(java.net.InetAddress address, int port, int backlog)(package private) voidbind0(java.lang.Object address, int port)voidclose()voidconnect(java.lang.String host, int port)voidconnect(java.net.InetAddress address, int port)(package private) voidconnect0(java.lang.Object address, int port)private byte[]getArray(java.nio.ByteBuffer src)booleangetDeferAccept()booleangetKeepAlive()java.net.InetSocketAddressgetLocalAddress()booleangetNoDelay()intgetNotsentLowat()private intgetOffset(java.nio.ByteBuffer src)byte[]getOption(int level, int option)intgetRecvBuffer()java.net.InetSocketAddressgetRemoteAddress()booleangetReuseAddr()booleangetReusePort()intgetSendBuffer()SslContextgetSslContext()<T> TgetSslOption(SslOption<T> option)booleangetTcpFastOpen()booleangetThinLinearTimeouts()intgetTimeout()intgetTos()private static intinitNatives(boolean preferIPv4)booleanisBlocking()booleanisOpen()voidlisten(int backlog)intread(byte[] data, int offset, int count, int flags)intread(java.nio.ByteBuffer dst)voidreadFully(byte[] data, int offset, int count)intreadRaw(long buf, int count, int flags)java.net.InetSocketAddressrecv(java.nio.ByteBuffer dst, int flags)(package private) intrecvFrom0(byte[] data, int offset, int maxSize, int flags, AddressHolder holder)(package private) intrecvFrom1(long buf, int maxSize, int flags, AddressHolder holder)intrecvMsg(Msg msg, int flags)(package private) intrecvMsg0(byte[] data, Msg msg, int flags)intsend(java.nio.ByteBuffer data, int flags, java.lang.String host, int port)intsend(java.nio.ByteBuffer src, int flags, java.net.InetAddress address, int port)longsendFile(java.io.RandomAccessFile file, long offset, long count)(package private) longsendFile0(int sourceFD, long offset, long count)intsendMsg(Msg msg, int flags)(package private) intsendMsg0(byte[] data, int cmsgType, int[] cmsgData, int flags)private intsendTo(java.nio.ByteBuffer src, int flags, java.lang.Object address, int port)(package private) intsendTo0(byte[] data, int offset, int size, int flags, java.lang.Object address, int port)(package private) intsendTo1(long buf, int size, int flags, java.lang.Object address, int port)voidsetBlocking(boolean blocking)voidsetDeferAccept(boolean deferAccept)voidsetKeepAlive(boolean keepAlive)voidsetNoDelay(boolean noDelay)voidsetNotsentLowat(int lowat)booleansetOption(int level, int option, byte[] value)voidsetRecvBuffer(int recvBuf)voidsetReuseAddr(boolean reuseAddr, boolean reusePort)voidsetSendBuffer(int sendBuf)voidsetTcpFastOpen(boolean tcpFastOpen)voidsetThinLinearTimeouts(boolean thinLto)voidsetTimeout(int timeout)voidsetTos(int tos)private static intsocket0(int domain, int type)SocketsslUnwrap()SocketsslWrap(SslContext context)(package private) static java.lang.ObjecttoNativeAddr(java.lang.String host, int port)intwrite(byte[] data, int offset, int count, int flags)intwrite(java.nio.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
-
-
-
-
Method Detail
-
isOpen
public final boolean isOpen()
-
accept
public NativeSocket accept() throws java.io.IOException
-
acceptNonBlocking
public NativeSocket acceptNonBlocking() throws java.io.IOException
- Overrides:
acceptNonBlockingin classSocket- Throws:
java.io.IOException
-
getLocalAddress
public final java.net.InetSocketAddress getLocalAddress()
- Specified by:
getLocalAddressin classSocket
-
getRemoteAddress
public final java.net.InetSocketAddress getRemoteAddress()
- Specified by:
getRemoteAddressin classSocket
-
sslWrap
public Socket sslWrap(SslContext context) throws java.io.IOException
-
getSslContext
public SslContext getSslContext()
- Specified by:
getSslContextin classSocket
-
getSslOption
public <T> T getSslOption(SslOption<T> option)
- Specified by:
getSslOptionin classSocket
-
connect
public void connect(java.net.InetAddress address, int port) throws java.io.IOException
-
connect
public void connect(java.lang.String host, int port) throws java.io.IOException
-
bind
public void bind(java.net.InetAddress address, int port, int backlog) throws java.io.IOException
-
bind
public void bind(java.lang.String host, int port, int backlog) throws java.io.IOException
-
listen
public void listen(int backlog) throws java.io.IOException
-
close
public void close()
-
writeRaw
public int writeRaw(long buf, int count, int flags) throws java.io.IOException
-
send
public int send(java.nio.ByteBuffer src, int flags, java.net.InetAddress address, int port) throws java.io.IOException
-
send
public int send(java.nio.ByteBuffer data, int flags, java.lang.String host, int port) throws java.io.IOException
-
sendTo
private int sendTo(java.nio.ByteBuffer src, int flags, java.lang.Object address, int port) throws java.io.IOException- Throws:
java.io.IOException
-
getArray
private byte[] getArray(java.nio.ByteBuffer src) throws java.lang.IllegalAccessException- Throws:
java.lang.IllegalAccessException
-
getOffset
private int getOffset(java.nio.ByteBuffer src) throws java.lang.IllegalAccessException- Throws:
java.lang.IllegalAccessException
-
write
public int write(byte[] data, int offset, int count, int flags) throws java.io.IOException
-
writeFully
public void writeFully(byte[] data, int offset, int count) throws java.io.IOException- Specified by:
writeFullyin classSocket- Throws:
java.io.IOException
-
readRaw
public int readRaw(long buf, int count, int flags) throws java.io.IOException
-
read
public int read(byte[] data, int offset, int count, int flags) throws java.io.IOException
-
recv
public java.net.InetSocketAddress recv(java.nio.ByteBuffer dst, int flags) throws java.io.IOException
-
readFully
public void readFully(byte[] data, int offset, int count) throws java.io.IOException
-
sendFile
public long sendFile(java.io.RandomAccessFile file, long offset, long count) throws java.io.IOException
-
read
public int read(java.nio.ByteBuffer dst) throws java.io.IOException- Throws:
java.io.IOException
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOException- Throws:
java.io.IOException
-
sendMsg
public int sendMsg(Msg msg, int flags) throws java.io.IOException
-
recvMsg
public int recvMsg(Msg msg, int flags) throws java.io.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
-
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
-
setOption
public boolean setOption(int level, int option, byte[] value)
-
toNativeAddr
static java.lang.Object toNativeAddr(java.lang.String host, int port) throws java.net.UnknownHostException- Throws:
java.net.UnknownHostException
-
initNatives
private static int initNatives(boolean preferIPv4)
-
socket0
private static int socket0(int domain, int type) throws java.io.IOException- Throws:
java.io.IOException
-
connect0
final void connect0(java.lang.Object address, int port) throws java.io.IOException- Throws:
java.io.IOException
-
bind0
final void bind0(java.lang.Object address, int port) throws java.io.IOException- Throws:
java.io.IOException
-
accept0
final int accept0(boolean nonblock) throws java.io.IOException- Throws:
java.io.IOException
-
sendFile0
long sendFile0(int sourceFD, long offset, long count) throws java.io.IOException- Throws:
java.io.IOException
-
sendTo0
final int sendTo0(byte[] data, int offset, int size, int flags, java.lang.Object address, int port) throws java.io.IOException- Throws:
java.io.IOException
-
sendTo1
final int sendTo1(long buf, int size, int flags, java.lang.Object address, int port) throws java.io.IOException- Throws:
java.io.IOException
-
recvFrom0
final int recvFrom0(byte[] data, int offset, int maxSize, int flags, AddressHolder holder) throws java.io.IOException- Throws:
java.io.IOException
-
recvFrom1
final int recvFrom1(long buf, int maxSize, int flags, AddressHolder holder) throws java.io.IOException- Throws:
java.io.IOException
-
sendMsg0
final int sendMsg0(byte[] data, int cmsgType, int[] cmsgData, int flags) throws java.io.IOException- Throws:
java.io.IOException
-
recvMsg0
final int recvMsg0(byte[] data, Msg msg, int flags) throws java.io.IOException- Throws:
java.io.IOException
-
-