Package one.nio.net
Class Socket
java.lang.Object
one.nio.net.Socket
- All Implemented Interfaces:
Closeable,AutoCloseable,ByteChannel,Channel,ReadableByteChannel,WritableByteChannel
- Direct Known Subclasses:
SelectableJavaSocket
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Socketaccept()voidabstract voidbind(InetAddress address, int port, int backlog) static SocketbindInet(InetAddress address, int port, int backlog) static Socketabstract voidclose()voidabstract voidconnect(InetAddress address, int port) static SocketconnectInet(InetAddress address, int port) static SocketconnectUnix(File unixPath) static Socketcreate()static Socketstatic Socketstatic SocketcreateUnixSocket(int type) static SocketfromFD(int fd) abstract booleanabstract booleanabstract InetSocketAddressabstract booleanabstract byte[]getOption(int level, int option) abstract intabstract InetSocketAddressabstract booleanabstract booleanabstract intabstract SslContextabstract <T> TgetSslOption(SslOption<T> option) abstract booleanabstract intabstract intgetTos()voidabstract booleanabstract booleanisOpen()abstract voidlisten(int backlog) intread(byte[] data, int offset, int count) abstract intread(byte[] data, int offset, int count, int flags) abstract voidreadFully(byte[] data, int offset, int count) abstract intreadRaw(long buf, int count, int flags) abstract InetSocketAddressrecv(ByteBuffer dst, int flags) abstract intintsend(ByteBuffer data, int flags, String host, int port) abstract intsend(ByteBuffer src, int flags, InetAddress address, int port) abstract longsendFile(RandomAccessFile file, long offset, long count) abstract intabstract voidsetBlocking(boolean blocking) abstract voidsetDeferAccept(boolean deferAccept) abstract voidsetKeepAlive(boolean keepAlive) abstract voidsetNoDelay(boolean noDelay) abstract booleansetOption(int level, int option, byte[] value) abstract voidsetRecvBuffer(int recvBuf) abstract voidsetReuseAddr(boolean reuseAddr, boolean reusePort) abstract voidsetSendBuffer(int sendBuf) abstract voidsetTcpFastOpen(boolean tcpFastOpen) abstract voidsetTimeout(int timeout) abstract voidsetTos(int tos) abstract Socketabstract SocketsslWrap(SslContext context) intwrite(byte[] data, int offset, int count) abstract intwrite(byte[] data, int offset, int count, int flags) abstract voidwriteFully(byte[] data, int offset, int count) abstract intwriteRaw(long buf, int count, int flags) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.nio.channels.ReadableByteChannel
readMethods inherited from interface java.nio.channels.WritableByteChannel
write
-
Field Details
-
AF_UNIX
public static final int AF_UNIX- See Also:
-
AF_INET
public static final int AF_INET- See Also:
-
AF_INET6
public static final int AF_INET6- See Also:
-
SOCK_STREAM
public static final int SOCK_STREAM- See Also:
-
SOCK_DGRAM
public static final int SOCK_DGRAM- See Also:
-
SOCK_RAW
public static final int SOCK_RAW- See Also:
-
SOCK_RDM
public static final int SOCK_RDM- See Also:
-
SOCK_SEQPACKET
public static final int SOCK_SEQPACKET- See Also:
-
NO_PORT
public static final int NO_PORT- See Also:
-
SOL_SOCKET
public static final int SOL_SOCKET- See Also:
-
SOL_IP
public static final int SOL_IP- See Also:
-
SOL_IPV6
public static final int SOL_IPV6- See Also:
-
SOL_TCP
public static final int SOL_TCP- See Also:
-
SOL_UDP
public static final int SOL_UDP- See Also:
-
MSG_OOB
public static final int MSG_OOB- See Also:
-
MSG_PEEK
public static final int MSG_PEEK- See Also:
-
MSG_DONTROUTE
public static final int MSG_DONTROUTE- See Also:
-
MSG_TRUNC
public static final int MSG_TRUNC- See Also:
-
MSG_DONTWAIT
public static final int MSG_DONTWAIT- See Also:
-
MSG_WAITALL
public static final int MSG_WAITALL- See Also:
-
MSG_MORE
public static final int MSG_MORE- See Also:
-
IPTOS_MINCOST
public static final int IPTOS_MINCOST- See Also:
-
IPTOS_RELIABILITY
public static final int IPTOS_RELIABILITY- See Also:
-
IPTOS_THROUGHPUT
public static final int IPTOS_THROUGHPUT- See Also:
-
IPTOS_LOWDELAY
public static final int IPTOS_LOWDELAY- See Also:
-
SO_DEBUG
public static final int SO_DEBUG- See Also:
-
SO_REUSEADDR
public static final int SO_REUSEADDR- See Also:
-
SO_TYPE
public static final int SO_TYPE- See Also:
-
SO_ERROR
public static final int SO_ERROR- See Also:
-
SO_DONTROUTE
public static final int SO_DONTROUTE- See Also:
-
SO_BROADCAST
public static final int SO_BROADCAST- See Also:
-
SO_SNDBUF
public static final int SO_SNDBUF- See Also:
-
SO_RCVBUF
public static final int SO_RCVBUF- See Also:
-
SO_KEEPALIVE
public static final int SO_KEEPALIVE- See Also:
-
SO_OOBINLINE
public static final int SO_OOBINLINE- See Also:
-
SO_NO_CHECK
public static final int SO_NO_CHECK- See Also:
-
SO_PRIORITY
public static final int SO_PRIORITY- See Also:
-
SO_LINGER
public static final int SO_LINGER- See Also:
-
SO_BSDCOMPAT
public static final int SO_BSDCOMPAT- See Also:
-
SO_REUSEPORT
public static final int SO_REUSEPORT- See Also:
-
SO_PASSCRED
public static final int SO_PASSCRED- See Also:
-
SO_PEERCRED
public static final int SO_PEERCRED- See Also:
-
SO_RCVLOWAT
public static final int SO_RCVLOWAT- See Also:
-
SO_SNDLOWAT
public static final int SO_SNDLOWAT- See Also:
-
SO_RCVTIMEO
public static final int SO_RCVTIMEO- See Also:
-
SO_SNDTIMEO
public static final int SO_SNDTIMEO- See Also:
-
TCP_NODELAY
public static final int TCP_NODELAY- See Also:
-
TCP_MAXSEG
public static final int TCP_MAXSEG- See Also:
-
TCP_CORK
public static final int TCP_CORK- See Also:
-
TCP_KEEPIDLE
public static final int TCP_KEEPIDLE- See Also:
-
TCP_KEEPINTVL
public static final int TCP_KEEPINTVL- See Also:
-
TCP_KEEPCNT
public static final int TCP_KEEPCNT- See Also:
-
TCP_SYNCNT
public static final int TCP_SYNCNT- See Also:
-
TCP_LINGER2
public static final int TCP_LINGER2- See Also:
-
TCP_DEFER_ACCEPT
public static final int TCP_DEFER_ACCEPT- See Also:
-
TCP_WINDOW_CLAMP
public static final int TCP_WINDOW_CLAMP- See Also:
-
TCP_INFO
public static final int TCP_INFO- See Also:
-
TCP_QUICKACK
public static final int TCP_QUICKACK- See Also:
-
TCP_CONGESTION
public static final int TCP_CONGESTION- See Also:
-
TCP_USER_TIMEOUT
public static final int TCP_USER_TIMEOUT- See Also:
-
-
Constructor Details
-
Socket
public Socket()
-
-
Method Details
-
isOpen
public abstract boolean isOpen() -
close
public abstract void close() -
accept
- Throws:
IOException
-
connect
- Throws:
IOException
-
bind
- Throws:
IOException
-
listen
- Throws:
IOException
-
writeRaw
- Throws:
IOException
-
write
- Throws:
IOException
-
writeFully
- Throws:
IOException
-
send
public abstract int send(ByteBuffer src, int flags, InetAddress address, int port) throws IOException - Throws:
IOException
-
readRaw
- Throws:
IOException
-
read
- Throws:
IOException
-
readFully
- Throws:
IOException
-
recv
- Throws:
IOException
-
sendFile
- Throws:
IOException
-
sendMsg
- Throws:
IOException
-
recvMsg
- Throws:
IOException
-
setBlocking
public abstract void setBlocking(boolean blocking) -
isBlocking
public abstract boolean isBlocking() -
setTimeout
public abstract void setTimeout(int timeout) -
getTimeout
public abstract int getTimeout() -
setKeepAlive
public abstract void setKeepAlive(boolean keepAlive) -
getKeepAlive
public abstract boolean getKeepAlive() -
setNoDelay
public abstract void setNoDelay(boolean noDelay) -
getNoDelay
public abstract boolean getNoDelay() -
setTcpFastOpen
public abstract void setTcpFastOpen(boolean tcpFastOpen) -
getTcpFastOpen
public abstract boolean getTcpFastOpen() -
setDeferAccept
public abstract void setDeferAccept(boolean deferAccept) -
getDeferAccept
public abstract boolean getDeferAccept() -
setReuseAddr
public abstract void setReuseAddr(boolean reuseAddr, boolean reusePort) -
getReuseAddr
public abstract boolean getReuseAddr() -
getReusePort
public abstract boolean getReusePort() -
setRecvBuffer
public abstract void setRecvBuffer(int recvBuf) -
getRecvBuffer
public abstract int getRecvBuffer() -
setSendBuffer
public abstract void setSendBuffer(int sendBuf) -
getSendBuffer
public abstract int getSendBuffer() -
setTos
public abstract void setTos(int tos) -
getTos
public abstract int getTos() -
getOption
public abstract byte[] getOption(int level, int option) -
setOption
public abstract boolean setOption(int level, int option, byte[] value) -
getLocalAddress
-
getRemoteAddress
-
sslWrap
- Throws:
IOException
-
sslUnwrap
-
getSslContext
-
getSslOption
-
acceptNonBlocking
- Throws:
IOException
-
connect
- Throws:
IOException
-
bind
- Throws:
IOException
-
send
- Throws:
IOException
-
handshake
- Throws:
IOException
-
write
- Throws:
IOException
-
read
- Throws:
IOException
-
create
- Throws:
IOException
-
createServerSocket
- Throws:
IOException
-
createDatagramSocket
- Throws:
IOException
-
createUnixSocket
- Throws:
IOException
-
connectInet
- Throws:
IOException
-
bindInet
- Throws:
IOException
-
connectUnix
- Throws:
IOException
-
bindUnix
- Throws:
IOException
-
fromFD
- Throws:
IOException
-