Package com.zerotier.sockets
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 intzfdFile descriptor used by lower native layer -
Constructor Summary
Constructors Constructor Description ZeroTierInputStream() -
Method Summary
Modifier and Type Method Description voidclose()Close the ZeroTierInputStreamintread()Read a single byte from the streamintread(byte[] destBuffer)Read from stream into bufferintread(byte[] destBuffer, int offset, int numBytes)Read from stream into buffer at offsetbyte[]readAllBytes()Read all available data from streamintreadNBytes(byte[] destBuffer, int offset, int numBytes)Read a given number of bytes from the stream into a bufferlongskip(long numBytes)Skip a certain number of byteslongtransferTo(java.io.OutputStream destStream)Transfer bytes from this stream to anotherMethods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, readNBytes, reset, skipNBytesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
zfd
public int zfdFile descriptor used by lower native layer
-
-
Constructor Details
-
ZeroTierInputStream
public ZeroTierInputStream()
-
-
Method Details
-
close
public void close() throws java.io.IOExceptionClose the ZeroTierInputStream- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- when an I/O error occurs
-
transferTo
public long transferTo(java.io.OutputStream destStream) throws java.io.IOExceptionTransfer bytes from this stream to another- Overrides:
transferToin classjava.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.IOExceptionRead a single byte from the stream- Specified by:
readin classjava.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.IOExceptionRead from stream into buffer- Overrides:
readin classjava.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.IOExceptionRead from stream into buffer at offset- Overrides:
readin classjava.io.InputStream- Parameters:
destBuffer- Destination bufferoffset- Where in the destination buffer bytes should be writtennumBytes- 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.IOExceptionRead all available data from stream- Overrides:
readAllBytesin classjava.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.IOExceptionRead a given number of bytes from the stream into a buffer- Overrides:
readNBytesin classjava.io.InputStream- Parameters:
destBuffer- Destination bufferoffset- Where in the destination buffer bytes should be writtennumBytes- 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.IOExceptionSkip a certain number of bytes- Overrides:
skipin classjava.io.InputStream- Parameters:
numBytes- Unused- Returns:
- Nothing.
- Throws:
java.io.IOException- when an I/O error occurs
-