Class ZeroTierInputStream

java.lang.Object
java.io.InputStream
com.zerotier.sockets.ZeroTierInputStream
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable

public class ZeroTierInputStream
extends java.io.InputStream
Extends InputStream using ZeroTier as a transport
  • Field Summary

    Fields
    Modifier and Type Field Description
    int zfd
    File descriptor used by lower native layer
  • Constructor Summary

    Constructors
    Constructor Description
    ZeroTierInputStream()  
  • Method Summary

    Modifier and Type Method Description
    void close()
    Close the ZeroTierInputStream
    int read()
    Read a single byte from the stream
    int read​(byte[] destBuffer)
    Read from stream into buffer
    int read​(byte[] destBuffer, int offset, int numBytes)
    Read from stream into buffer at offset
    byte[] readAllBytes()
    Read all available data from stream
    int readNBytes​(byte[] destBuffer, int offset, int numBytes)
    Read a given number of bytes from the stream into a buffer
    long skip​(long numBytes)
    Skip a certain number of bytes
    long transferTo​(java.io.OutputStream destStream)
    Transfer bytes from this stream to another

    Methods inherited from class java.io.InputStream

    available, mark, markSupported, nullInputStream, readNBytes, reset, skipNBytes

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • zfd

      public int zfd
      File descriptor used by lower native layer
  • Constructor Details

    • ZeroTierInputStream

      public ZeroTierInputStream()
  • Method Details

    • close

      public void close() throws java.io.IOException
      Close the ZeroTierInputStream
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Overrides:
      close in class java.io.InputStream
      Throws:
      java.io.IOException - when an I/O error occurs
    • transferTo

      public long transferTo​(java.io.OutputStream destStream) throws java.io.IOException
      Transfer bytes from this stream to another
      Overrides:
      transferTo in class java.io.InputStream
      Parameters:
      destStream - Unused
      Returns:
      Number of bytes transferred
      Throws:
      java.io.IOException - when an I/O error occurs
    • read

      public int read() throws java.io.IOException
      Read a single byte from the stream
      Specified by:
      read in class java.io.InputStream
      Returns:
      Single byte read
      Throws:
      java.io.IOException - when an I/O error occurs
    • read

      public int read​(byte[] destBuffer) throws java.io.IOException
      Read from stream into buffer
      Overrides:
      read in class java.io.InputStream
      Parameters:
      destBuffer - Destination buffer
      Returns:
      Number of bytes read
      Throws:
      java.io.IOException - when an I/O error occurs
    • read

      public int read​(byte[] destBuffer, int offset, int numBytes) throws java.io.IOException
      Read from stream into buffer at offset
      Overrides:
      read in class java.io.InputStream
      Parameters:
      destBuffer - Destination buffer
      offset - Where in the destination buffer bytes should be written
      numBytes - Number of bytes to read
      Returns:
      Number of bytes read.
      Throws:
      java.io.IOException - when an I/O error occurs
    • readAllBytes

      public byte[] readAllBytes() throws java.io.IOException
      Read all available data from stream
      Overrides:
      readAllBytes in class java.io.InputStream
      Returns:
      Array of bytes
      Throws:
      java.io.IOException - when an I/O error occurs
    • readNBytes

      public int readNBytes​(byte[] destBuffer, int offset, int numBytes) throws java.io.IOException
      Read a given number of bytes from the stream into a buffer
      Overrides:
      readNBytes in class java.io.InputStream
      Parameters:
      destBuffer - Destination buffer
      offset - Where in the destination buffer bytes should be written
      numBytes - Number of bytes to read
      Returns:
      Nothing.
      Throws:
      java.io.IOException - when an I/O error occurs
    • skip

      public long skip​(long numBytes) throws java.io.IOException
      Skip a certain number of bytes
      Overrides:
      skip in class java.io.InputStream
      Parameters:
      numBytes - Unused
      Returns:
      Nothing.
      Throws:
      java.io.IOException - when an I/O error occurs