public class DatagramStream extends StreamImpl
Unlike VfsStream, when the read() throws and IOException or a SocketException, SocketStream will throw a ClientDisconnectException.
_nullPath, _path| Constructor and Description |
|---|
DatagramStream(java.net.DatagramSocket s) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRead()
Returns true since the socket stream can be read.
|
boolean |
canWrite()
Returns true if this is a writable stream.
|
void |
close()
Closes the underlying sockets and socket streams.
|
void |
closeWrite()
Closes the write half of the stream.
|
int |
getAvailable()
Returns the number of bytes available to be read from the input stream.
|
java.io.InputStream |
getInputStream() |
java.io.OutputStream |
getOutputStream() |
long |
getPosition()
Returns the position.
|
boolean |
getThrowReadInterrupts()
If true, throws read interrupts instead of returning an end of
fail.
|
long |
getTotalReadBytes() |
long |
getTotalWriteBytes() |
boolean |
hasSkip()
Returns true if stream is readable and bytes can be skipped.
|
int |
read(byte[] buf,
int offset,
int length)
Reads bytes from the socket.
|
int |
readTimeout(byte[] buf,
int offset,
int length,
long timeout)
Reads bytes from the socket.
|
void |
resetTotalBytes()
Flushes the socket.
|
boolean |
setPosition(long offset) |
void |
setThrowReadInterrupts(boolean allowThrow)
If true, throws read interrupts instead of returning an end of
fail.
|
long |
skip(long n)
Skips bytes in the file.
|
void |
unread()
Unread the last byte.
|
void |
write(byte[] buf,
int offset,
int length,
boolean isEnd)
Writes bytes to the socket.
|
clearWrite, flush, flushBuffer, flushToDisk, getAttribute, getAttributeNames, getFlushOnNewline, getNewline, getPath, getReadBuffer, getReadPosition, isClosed, isEof, isMmapEnabled, isSendfileEnabled, readNonBlock, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, write, writeMmap, writeSendfilepublic java.io.InputStream getInputStream()
public java.io.OutputStream getOutputStream()
public void setThrowReadInterrupts(boolean allowThrow)
public boolean getThrowReadInterrupts()
public long getPosition()
public boolean setPosition(long offset)
public void unread()
throws java.io.IOException
java.io.IOExceptionpublic boolean hasSkip()
hasSkip in class StreamImplpublic boolean canRead()
canRead in class StreamImplpublic long skip(long n)
throws java.io.IOException
skip in class StreamImpln - the number of bytes to skipjava.io.IOExceptionpublic int read(byte[] buf,
int offset,
int length)
throws java.io.IOException
read in class StreamImplbuf - byte buffer receiving the bytesoffset - offset into the bufferlength - number of bytes to readthrows - ClientDisconnectException if the connection is droppedjava.io.IOExceptionpublic int readTimeout(byte[] buf,
int offset,
int length,
long timeout)
throws java.io.IOException
readTimeout in class StreamImplbuf - byte buffer receiving the bytesoffset - offset into the bufferlength - number of bytes to readthrows - ClientDisconnectException if the connection is droppedjava.io.IOExceptionpublic int getAvailable()
throws java.io.IOException
getAvailable in class StreamImpljava.io.IOExceptionpublic boolean canWrite()
StreamImplcanWrite in class StreamImplpublic void write(byte[] buf,
int offset,
int length,
boolean isEnd)
throws java.io.IOException
write in class StreamImplbuf - byte buffer containing the bytesoffset - offset into the bufferlength - number of bytes to readisEnd - if the write is at a close.throws - ClientDisconnectException if the connection is droppedjava.io.IOExceptionpublic void resetTotalBytes()
public long getTotalReadBytes()
public long getTotalWriteBytes()
public void closeWrite()
throws java.io.IOException
closeWrite in class StreamImpljava.io.IOExceptionpublic void close()
throws java.io.IOException
close in class StreamImpljava.io.IOException