java.lang.Object
net.i2p.client.streaming.impl.I2PSocketFull
All Implemented Interfaces:
Closeable, AutoCloseable, I2PSocket

class I2PSocketFullextends Object implements I2PSocket
Bridge between the full streaming lib and the I2PSocket API.
  • Field Details

    • log

      private final Log log
      Logger for this class.
    • _connection

      private volatile Connection _connection
      The connection the socket is full on, if any.
    • _remotePeer

      private final Destination _remotePeer
      The remote end of the connection.
    • _localPeer

      private final Destination _localPeer
      The local end of the connection.
    • _closed

      private final AtomicBoolean _closed
      True once the event has been consumed.
  • Constructor Details

    • I2PSocketFull

      public I2PSocketFull(Connection con, I2PAppContext context)
      Bridge between a connection and the I2PSocket API.
      Parameters:
      con - the underlying connection, may be null
      context - the I2P application context
  • Method Details

    • close

      public void close() throws IOException
      Closes this socket.

      Nonblocking: Any thread currently blocked in an I/O operation upon this socket will throw an IOException. Once a socket has been closed, it is not available for further networking use (i.e. can't be reconnected or rebound). A new socket needs to be created. Closing this socket will also close the socket's InputStream and OutputStream.

      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if an I/O error occurs
    • reset

      public void reset() throws IOException
      Resets and closes this socket. Sends a RESET indication to the far-end. This is the equivalent of setSoLinger(true, 0) followed by close() on a Java Socket.

      Nonblocking. Any thread currently blocked in an I/O operation upon this socket will throw an IOException. Once a socket has been reset, it is not available for further networking use (i.e. can't be reconnected or rebound). A new socket needs to be created. Resetting this socket will also close the socket's InputStream and OutputStream.

      Specified by:
      reset in interface I2PSocket
      Throws:
      IOException - if an I/O error occurs
    • getConnection

      Connection getConnection()
      Underlying connection.
      Returns:
      the Connection carrying this socket's packets
    • getInputStream

      public InputStream getInputStream() throws IOException
      Stream for data received on this connection.
      Specified by:
      getInputStream in interface I2PSocket
      Returns:
      non-null input stream
      Throws:
      IOException - if the socket is closed
    • getOptions

      public I2PSocketOptions getOptions()
      Socket options for this socket.
      Specified by:
      getOptions in interface I2PSocket
      Returns:
      the socket options, or null if the socket is closed
    • getOutputStream

      public OutputStream getOutputStream() throws IOException
      Output stream for sending data over this connection.
      Specified by:
      getOutputStream in interface I2PSocket
      Returns:
      non-null output stream
      Throws:
      IOException - if the socket is closed
    • getPeerDestination

      public Destination getPeerDestination()
      Gets the remote peer's destination.
      Specified by:
      getPeerDestination in interface I2PSocket
      Returns:
      the destination at the other end of the connection
    • getReadTimeout

      public long getReadTimeout()
      Read timeout for this socket.
      Specified by:
      getReadTimeout in interface I2PSocket
      Returns:
      the read timeout in milliseconds, or -1 if no options are set
    • getThisDestination

      public Destination getThisDestination()
      Gets this side's destination.
      Specified by:
      getThisDestination in interface I2PSocket
      Returns:
      the destination of the local session
    • setOptions

      public void setOptions(I2PSocketOptions options)
      New socket options.
      Specified by:
      setOptions in interface I2PSocket
      Parameters:
      options - the new socket options
    • setReadTimeout

      public void setReadTimeout(long ms)
      Read timeout in milliseconds.
      Specified by:
      setReadTimeout in interface I2PSocket
      Parameters:
      ms - the read timeout in milliseconds
    • isClosed

      public boolean isClosed()
      Whether the socket is closed or not connected.
      Specified by:
      isClosed in interface I2PSocket
      Returns:
      true if the socket is closed or not connected
    • destroy

      void destroy()
      Release the connection reference.
    • destroy2

      void destroy2()
    • getPort

      public int getPort()
      The remote port.
      Specified by:
      getPort in interface I2PSocket
      Returns:
      the port or 0 if unknown
    • getLocalPort

      public int getLocalPort()
      The local port.
      Specified by:
      getLocalPort in interface I2PSocket
      Returns:
      the port or 0 if unknown
    • getLifetimeBytesSent

      public long getLifetimeBytesSent()
      Total bytes sent over the socket's lifetime.
      Specified by:
      getLifetimeBytesSent in interface I2PSocket
      Returns:
      total bytes sent over this socket's lifetime, or 0 if not connected
    • getLifetimeBytesReceived

      public long getLifetimeBytesReceived()
      Total bytes received over the socket's lifetime.
      Specified by:
      getLifetimeBytesReceived in interface I2PSocket
      Returns:
      total bytes received over this socket's lifetime, or 0 if not connected
    • toString

      public String toString()
      Description of this socket.
      Overrides:
      toString in class Object