public final class SockInputStream extends InputStream
SockInputStream
is a inputstream based on a socket. Due to memcached
protocol, we can only read specified length from the socket, you have to set
the byte length to read before invoke read.InputStream
Constructor and Description |
---|
SockInputStream(SchoonerSockIO sock)
Constructor.
|
SockInputStream(SchoonerSockIO sock,
int limit)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
available() |
byte[] |
getBuffer()
get all left bytes from the socket.
|
String |
getLine()
get a line from the socket.
|
int |
getWillRead()
get length of to-be-read.
|
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
willRead(int limit)
set limited length to read.
|
close, mark, markSupported, read, reset, skip
public SockInputStream(SchoonerSockIO sock, int limit) throws IOException
sock
- SchoonerSockIO
, read from this socket.limit
- limited length to read from specified socket.IOException
- error happened in reading.public SockInputStream(SchoonerSockIO sock) throws IOException
sock
- SchoonerSockIO
, read from this socket.IOException
- error happened in reading.public final int getWillRead()
public final void willRead(int limit)
length
- length to set.public final int read() throws IOException
read
in class InputStream
IOException
public final int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public final byte[] getBuffer() throws IOException
IOException
- error happened in reading.public final String getLine() throws IOException
IOException
- error happend in reading.public int available() throws IOException
available
in class InputStream
IOException
Copyright © 2013 Schooner Information Technology. All Rights Reserved.