Interface HelidonSocket

All Superinterfaces:
SocketContext, Supplier<byte[]>
All Known Implementing Classes:
DirectSocket, NioSocket, PlainSocket, TlsNioSocket, TlsSocket

public interface HelidonSocket extends SocketContext, Supplier<byte[]>
Socket abstraction to allow usage of TLS or even non-socket transport.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Close the underlying socket.
    void
    Sets the socket to idle mode.
    boolean
    Check if socket is connected.
    default String
    Protocol that was negotiated.
    default boolean
    Whether a protocol was negotiated by the socket (such as ALPN when using TLS).
    int
    read(BufferData buffer)
    Deprecated, for removal: This API element is subject to removal in a future version.
    this method is not used in Helidon, and will be removed
    void
    write(BufferData buffer)
    Write teh buffer to the underlying socket.

    Methods inherited from interface io.helidon.common.socket.SocketContext

    childSocketId, isSecure, localPeer, log, log, remotePeer, socketId

    Methods inherited from interface java.util.function.Supplier

    get
  • Method Details

    • close

      void close()
      Close the underlying socket.
    • idle

      void idle()
      Sets the socket to idle mode. Idle mode expects no bytes coming over the socket but keeps reading exactly one byte in case connection is severed. Idle mode should be used in case of client side connection caching.
    • isConnected

      boolean isConnected()
      Check if socket is connected.
      Returns:
      true if connected
    • read

      @Deprecated(forRemoval=true, since="4.4.0") int read(BufferData buffer)
      Deprecated, for removal: This API element is subject to removal in a future version.
      this method is not used in Helidon, and will be removed
      Read bytes from the socket. This method blocks until at least 1 byte is available.
      Parameters:
      buffer - buffer to read to
      Returns:
      number of bytes read
    • write

      void write(BufferData buffer)
      Write teh buffer to the underlying socket. This method blocks until all bytes are written.
      Parameters:
      buffer - buffer to write
    • protocolNegotiated

      default boolean protocolNegotiated()
      Whether a protocol was negotiated by the socket (such as ALPN when using TLS).
      Returns:
      whether a protocol was negotiated
    • protocol

      default String protocol()
      Protocol that was negotiated.
      Returns:
      protocol name
      Throws:
      NoSuchElementException - in case there is no negotiated protocol