Interface Transport

All Superinterfaces:
Socket
All Known Implementing Classes:
SecureTransport, SocketTransport

public interface Transport extends Socket
The Transport interface represents a low level means to deliver content to the connected client. Typically this will be a connected, non-blocking, TCP connection. However, for tests and other purposes this may be adapted. The general contract of the transport is that it provides non-blocking reads and blocking writes. Blocking writes are required to ensure that memory does not build up in output buffers during high load periods.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This is used to close the transport and the underlying socket.
    void
    This method is used to flush the contents of the buffer to the client.
    This is used to acquire the SSL certificate used when the server is using a HTTPS connection.
    int
    read(ByteBuffer buffer)
    This is used to perform a non-blocking read on the transport.
    void
    write(ByteBuffer buffer)
    This method is used to deliver the provided buffer of bytes to the underlying transport.

    Methods inherited from interface org.simpleframework.transport.Socket

    getAttributes, getChannel, getEngine, getTrace
  • Method Details

    • getCertificate

      Certificate getCertificate() throws IOException
      This is used to acquire the SSL certificate used when the server is using a HTTPS connection. For plain text connections or connections that use a security mechanism other than SSL this will be null. This is only available when the connection makes specific use of an SSL engine to secure the connection.
      Returns:
      this returns the associated SSL certificate if any
      Throws:
      IOException
    • read

      int read(ByteBuffer buffer) throws IOException
      This is used to perform a non-blocking read on the transport. If there are no bytes available on the input buffers then this method will return zero and the buffer will remain the same. If there is data and the buffer can be filled then this will return the number of bytes read. Finally if the socket is closed this will return a -1 value.
      Parameters:
      buffer - this is the buffer to append the bytes to
      Returns:
      this returns the number of bytes that have been read
      Throws:
      IOException
    • write

      void write(ByteBuffer buffer) throws IOException
      This method is used to deliver the provided buffer of bytes to the underlying transport. Depending on the connection type the array may be encoded for SSL transport or send directly. Any implementation may choose to buffer the bytes for performance.
      Parameters:
      buffer - this is the buffer of bytes to send to the client
      Throws:
      IOException
    • flush

      void flush() throws IOException
      This method is used to flush the contents of the buffer to the client. This method will block not block but will simply flush any data to the underlying transport. Internally the data will be queued for delivery to the connected entity.
      Throws:
      IOException
    • close

      void close() throws IOException
      This is used to close the transport and the underlying socket. If a close is performed on the transport then no more bytes can be read from or written to the transport and the client will receive a connection close on their side.
      Throws:
      IOException