@Module public class SocketChannelStream extends StreamImpl
Unlike VfsStream, when the read() throws and IOException or a SocketException, SocketStream will throw a ClientDisconnectException.
_nullPath, _path| Constructor and Description |
|---|
SocketChannelStream() |
SocketChannelStream(java.nio.channels.SocketChannel channel) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRead()
Returns true since the socket stream can be read.
|
void |
close()
Closes the underlying sockets and socket streams.
|
int |
getAvailable()
Returns the number of bytes available to be read from the input stream.
|
byte[] |
getNewline()
Returns the stream's natural newline character.
|
boolean |
getThrowReadInterrupts()
If true, throws read interrupts instead of returning an end of
fail.
|
boolean |
hasSkip()
Returns true if stream is readable and bytes can be skipped.
|
void |
init(java.nio.channels.SocketChannel channel)
Initialize the SocketStream with a new Socket.
|
int |
read(byte[] buf,
int offset,
int length)
Reads bytes from the socket.
|
void |
setNewline(byte[] newline) |
void |
setThrowReadInterrupts(boolean allowThrow)
If true, throws read interrupts instead of returning an end of
fail.
|
java.lang.String |
toString() |
canWrite, clearWrite, closeWrite, flush, flushBuffer, flushToDisk, getAttribute, getAttributeNames, getFlushOnNewline, getPath, getReadBuffer, getReadPosition, isClosed, isEof, isMmapEnabled, isSendfileEnabled, readNonBlock, readTimeout, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, skip, write, write, writeMmap, writeSendfilepublic SocketChannelStream()
public SocketChannelStream(java.nio.channels.SocketChannel channel)
public void init(java.nio.channels.SocketChannel channel)
s - the new socket.public void setThrowReadInterrupts(boolean allowThrow)
public boolean getThrowReadInterrupts()
public void setNewline(byte[] newline)
public byte[] getNewline()
StreamImplgetNewline in class StreamImplpublic boolean hasSkip()
hasSkip in class StreamImplpublic boolean canRead()
canRead in class StreamImplpublic 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 getAvailable()
throws java.io.IOException
getAvailable in class StreamImpljava.io.IOExceptionpublic void close()
throws java.io.IOException
close in class StreamImpljava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object