|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.danga.MemCached.SockIOPool.SockIO
public static class SockIOPool.SockIO
MemCached Java client, utility class for Socket IO. This class is a wrapper around a Socket and its streams.
| Field Summary | |
|---|---|
private java.lang.String |
host
|
private java.io.DataInputStream |
in
|
private static org.apache.log4j.Logger |
log
|
private java.io.BufferedOutputStream |
out
|
private SockIOPool |
pool
|
private java.net.Socket |
sock
|
| Constructor Summary | |
|---|---|
SockIOPool.SockIO(SockIOPool pool,
java.lang.String host,
int timeout,
int connectTimeout,
boolean noDelay)
creates a new SockIO object wrapping a socket connection to host:port, and its input and output streams |
|
SockIOPool.SockIO(SockIOPool pool,
java.lang.String host,
int port,
int timeout,
int connectTimeout,
boolean noDelay)
creates a new SockIO object wrapping a socket connection to host:port, and its input and output streams |
|
| Method Summary | |
|---|---|
void |
clearEOL()
reads up to end of line and returns nothing |
(package private) void |
close()
sets closed flag and checks in to connection pool but does not close connections |
protected void |
finalize()
Hack to reap any leaking children. |
(package private) void |
flush()
flushes output stream |
java.nio.channels.SocketChannel |
getChannel()
Lets caller get access to underlying channel. |
java.lang.String |
getHost()
returns the host this socket is connected to |
protected static java.net.Socket |
getSocket(java.lang.String host,
int port,
int timeout)
Method which gets a connection from SocketChannel. |
int |
hashCode()
use the sockets hashcode for this object so we can key off of SockIOs |
(package private) boolean |
isAlive()
|
(package private) boolean |
isConnected()
checks if the connection is open |
int |
read(byte[] b)
reads length bytes into the passed in byte array from dtream |
java.lang.String |
readLine()
reads a line intentionally not using the deprecated readLine method from DataInputStream |
java.lang.String |
toString()
returns the string representation of this socket |
void |
trueClose()
closes socket and all streams connected to it |
void |
trueClose(boolean addToDeadPool)
closes socket and all streams connected to it |
(package private) void |
write(byte[] b)
writes a byte array to the output stream |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static org.apache.log4j.Logger log
private SockIOPool pool
private java.lang.String host
private java.net.Socket sock
private java.io.DataInputStream in
private java.io.BufferedOutputStream out
| Constructor Detail |
|---|
public SockIOPool.SockIO(SockIOPool pool,
java.lang.String host,
int port,
int timeout,
int connectTimeout,
boolean noDelay)
throws java.io.IOException,
java.net.UnknownHostException
pool - Pool this object is tied tohost - host to connect toport - port to connect totimeout - int ms to block on data for readconnectTimeout - timeout (in ms) for initial connectionnoDelay - TCP NODELAY option?
java.io.IOException - if an io error occurrs when creating socket
java.net.UnknownHostException - if hostname is invalid
public SockIOPool.SockIO(SockIOPool pool,
java.lang.String host,
int timeout,
int connectTimeout,
boolean noDelay)
throws java.io.IOException,
java.net.UnknownHostException
host - hostname:porttimeout - read timeout value for connected socketconnectTimeout - timeout for initial connectionsnoDelay - TCP NODELAY option?
java.io.IOException - if an io error occurrs when creating socket
java.net.UnknownHostException - if hostname is invalid| Method Detail |
|---|
protected static java.net.Socket getSocket(java.lang.String host,
int port,
int timeout)
throws java.io.IOException
host - host to establish connection toport - port on that hosttimeout - connection timeout in ms
java.io.IOException - if errors connecting or if connection times outpublic java.nio.channels.SocketChannel getChannel()
public java.lang.String getHost()
public void trueClose()
throws java.io.IOException
java.io.IOException - if fails to close streams or socket
public void trueClose(boolean addToDeadPool)
throws java.io.IOException
java.io.IOException - if fails to close streams or socketvoid close()
boolean isConnected()
boolean isAlive()
public java.lang.String readLine()
throws java.io.IOException
readLine in interface LineInputStreamjava.io.IOException - if io problems during read
public void clearEOL()
throws java.io.IOException
clearEOL in interface LineInputStreamjava.io.IOException - if io problems during read
public int read(byte[] b)
throws java.io.IOException
read in interface LineInputStreamb - byte array
java.io.IOException - if io problems during read
void flush()
throws java.io.IOException
java.io.IOException - if io problems during read
void write(byte[] b)
throws java.io.IOException
b - byte array to write
java.io.IOException - if an io error happenspublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
protected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||