Class PlainSocket

java.lang.Object
io.helidon.common.socket.PlainSocket
All Implemented Interfaces:
HelidonSocket, SocketContext, Supplier<byte[]>
Direct Known Subclasses:
TlsSocket

public sealed class PlainSocket extends Object implements HelidonSocket permits TlsSocket
Helidon socket that is based on plaintext.
  • Constructor Details

    • PlainSocket

      protected PlainSocket(Socket delegate, String childSocketId, String socketId)
      Plain socket.
      Parameters:
      delegate - delegate socket
      childSocketId - channel id
      socketId - server channel id
  • Method Details

    • server

      public static PlainSocket server(Socket delegate, String channelId, String serverChannelId)
      Create a new server socket.
      Parameters:
      delegate - underlying socket
      channelId - channel id
      serverChannelId - server channel id
      Returns:
      a new plain socket
    • client

      public static PlainSocket client(Socket delegate, String channelId)
      Create a new client socket.
      Parameters:
      delegate - underlying socket
      channelId - channel id
      Returns:
      a new plain socket
    • remotePeer

      public PeerInfo remotePeer()
      Description copied from interface: SocketContext
      Remote peer information.
      Specified by:
      remotePeer in interface SocketContext
      Returns:
      peer info
    • localPeer

      public PeerInfo localPeer()
      Description copied from interface: SocketContext
      Local peer information.
      Specified by:
      localPeer in interface SocketContext
      Returns:
      peer info
    • isSecure

      public boolean isSecure()
      Description copied from interface: SocketContext
      Whether the request is secure.
      Specified by:
      isSecure in interface SocketContext
      Returns:
      whether secure
    • socketId

      public String socketId()
      Description copied from interface: SocketContext
      Main socket id. This is the server socket id for server side, connection id for client side.
      Specified by:
      socketId in interface SocketContext
      Returns:
      socket id
    • childSocketId

      public String childSocketId()
      Description copied from interface: SocketContext
      Child socket id. This is the connection socket id for server side. For client side, this may be additional identification of a request (pipeline id, stream id).
      Specified by:
      childSocketId in interface SocketContext
      Returns:
      child socket id, never null
    • close

      public void close()
      Description copied from interface: HelidonSocket
      Close the underlying socket.
      Specified by:
      close in interface HelidonSocket
    • read

      public int read(BufferData buffer)
      Description copied from interface: HelidonSocket
      Read bytes from the socket. This method blocks until at least 1 byte is available.
      Specified by:
      read in interface HelidonSocket
      Parameters:
      buffer - buffer to read to
      Returns:
      number of bytes read
    • write

      public void write(BufferData buffer)
      Description copied from interface: HelidonSocket
      Write teh buffer to the underlying socket. This method blocks until all bytes are written.
      Specified by:
      write in interface HelidonSocket
      Parameters:
      buffer - buffer to write
    • get

      public byte[] get()
      Specified by:
      get in interface Supplier<byte[]>