|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.caucho.vfs.StreamImpl
com.caucho.vfs.SocketStream
@Module public class SocketStream
Specialized stream to handle sockets.
Unlike VfsStream, when the read() throws and IOException or a SocketException, SocketStream will throw a ClientDisconnectException.
| Field Summary |
|---|
| Fields inherited from class com.caucho.vfs.StreamImpl |
|---|
_nullPath, _path |
| Constructor Summary | |
|---|---|
SocketStream()
|
|
SocketStream(java.net.Socket s)
|
|
| Method Summary | |
|---|---|
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. |
void |
flush()
Flushes the socket. |
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. |
long |
getTotalReadBytes()
|
long |
getTotalWriteBytes()
|
boolean |
hasSkip()
Returns true if stream is readable and bytes can be skipped. |
void |
init(java.io.InputStream is,
java.io.OutputStream os)
Initialize the SocketStream with a new Socket. |
void |
init(java.net.Socket s)
Initialize the SocketStream with a new Socket. |
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()
|
void |
setNewline(byte[] newline)
|
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. |
java.lang.String |
toString()
|
void |
write(byte[] buf,
int offset,
int length,
boolean isEnd)
Writes bytes to the socket. |
| Methods inherited from class com.caucho.vfs.StreamImpl |
|---|
clearWrite, flushBuffer, flushToDisk, getAttribute, getAttributeNames, getFlushOnNewline, getPath, getReadBuffer, getReadPosition, isClosed, isEof, readNonBlock, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SocketStream()
public SocketStream(java.net.Socket s)
| Method Detail |
|---|
public void init(java.net.Socket s)
s - the new socket.
public void init(java.io.InputStream is,
java.io.OutputStream os)
s - the new socket.public void setThrowReadInterrupts(boolean allowThrow)
public boolean getThrowReadInterrupts()
public void setNewline(byte[] newline)
public byte[] getNewline()
StreamImpl
getNewline in class StreamImplpublic boolean hasSkip()
hasSkip in class StreamImpl
public long skip(long n)
throws java.io.IOException
skip in class StreamImpln - the number of bytes to skip
java.io.IOExceptionpublic boolean canRead()
canRead in class StreamImpl
public 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 read
throws - ClientDisconnectException if the connection is dropped
java.io.IOException
public 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 read
throws - ClientDisconnectException if the connection is dropped
java.io.IOException
public int getAvailable()
throws java.io.IOException
getAvailable in class StreamImpljava.io.IOExceptionpublic boolean canWrite()
StreamImpl
canWrite in class StreamImpl
public 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 dropped
java.io.IOException
public void flush()
throws java.io.IOException
flush in class StreamImpljava.io.IOExceptionpublic void resetTotalBytes()
public long getTotalReadBytes()
public long getTotalWriteBytes()
public void closeWrite()
throws java.io.IOException
closeWrite in class StreamImpljava.io.IOException
public void close()
throws java.io.IOException
close in class StreamImpljava.io.IOExceptionpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||