Class NioTcpSocket

  • All Implemented Interfaces:
    AutoCloseable, ISocket

    public class NioTcpSocket
    extends Object
    implements ISocket
    Default TCP Socket implementation which uses NIO as the underlying platform.
    • Constructor Detail

      • NioTcpSocket

        public NioTcpSocket​(SocketChannel channel)
        Creates a new Socket with an pre-exisiting channel. The channel must be in non-blocking mode.
        Parameters:
        channel - The pre-exisiting channel.
        Throws:
        IllegalArgumentException - When the channel is in blocking mode.
      • NioTcpSocket

        public NioTcpSocket()
        Creates a new non-blocking TCP Socket.
    • Method Detail

      • isConnected

        public boolean isConnected()
        Specified by:
        isConnected in interface ISocket
        Returns:
        true if the connection is successfully established. Otherwise false.
      • isClosed

        public boolean isClosed()
        Description copied from interface: ISocket
        Checks if the connection has been closed
        Specified by:
        isClosed in interface ISocket
        Returns:
        true if the connection is closing/closed
      • isInputShutdown

        public boolean isInputShutdown()
        Description copied from interface: ISocket
        Checks if there will be no more data incoming
        Specified by:
        isInputShutdown in interface ISocket
        Returns:
        true if EOF has been found
      • isOutputShutdown

        public boolean isOutputShutdown()
        Description copied from interface: ISocket
        Checks if no more data can be send on this socket
        Specified by:
        isOutputShutdown in interface ISocket
        Returns:
        true if EOF has been send