SockIOPool.SockIO Class Reference

Inherits com::meetup::memcached::LineInputStream.

Collaboration diagram for SockIOPool.SockIO:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void clearEOL () throws IOException
SocketChannel getChannel ()
String getHost ()
int hashCode ()
int read (byte[] b) throws IOException
String readLine () throws IOException
 SockIO (SockIOPool pool, String host, int timeout, int connectTimeout, boolean noDelay) throws IOException, UnknownHostException
 SockIO (SockIOPool pool, String host, int port, int timeout, int connectTimeout, boolean noDelay) throws IOException, UnknownHostException
String toString ()
void trueClose (boolean addToDeadPool) throws IOException
void trueClose () throws IOException

Protected Member Functions

void finalize () throws Throwable

Static Protected Member Functions

static Socket getSocket (String host, int port, int timeout) throws IOException

Package Functions

void close ()
void flush () throws IOException
boolean isAlive ()
boolean isConnected ()
void write (byte[] b) throws IOException

Private Attributes

String host
DataInputStream in
BufferedOutputStream out
SockIOPool pool
Socket sock

Static Private Attributes

static Logger log


Detailed Description

MemCached client for Java, utility class for Socket IO.

This class is a wrapper around a Socket and its streams.

Author:
greg whalin <greg@meetup.com>

Richard 'toast' Russo <russor@msoe.edu>

Version:
1.5

Constructor & Destructor Documentation

SockIO ( SockIOPool  pool,
String  host,
int  port,
int  timeout,
int  connectTimeout,
boolean  noDelay 
) throws IOException, UnknownHostException

creates a new SockIO object wrapping a socket connection to host:port, and its input and output streams

Parameters:
pool Pool this object is tied to
host host to connect to
port port to connect to
timeout int ms to block on data for read
connectTimeout timeout (in ms) for initial connection
noDelay TCP NODELAY option?
Exceptions:
IOException if an io error occurrs when creating socket
UnknownHostException if hostname is invalid

SockIO ( SockIOPool  pool,
String  host,
int  timeout,
int  connectTimeout,
boolean  noDelay 
) throws IOException, UnknownHostException

creates a new SockIO object wrapping a socket connection to host:port, and its input and output streams

Parameters:
host hostname:port
timeout read timeout value for connected socket
connectTimeout timeout for initial connections
noDelay TCP NODELAY option?
Exceptions:
IOException if an io error occurrs when creating socket
UnknownHostException if hostname is invalid


Member Function Documentation

void clearEOL (  )  throws IOException

reads up to end of line and returns nothing

Exceptions:
IOException if io problems during read

Implements LineInputStream.

void close (  )  [package]

sets closed flag and checks in to connection pool but does not close connections

void finalize (  )  throws Throwable [protected]

Hack to reap any leaking children.

void flush (  )  throws IOException [package]

flushes output stream

Exceptions:
IOException if io problems during read

SocketChannel getChannel (  ) 

Lets caller get access to underlying channel.

Returns:
the backing SocketChannel

String getHost (  ) 

returns the host this socket is connected to

Returns:
String representation of host (hostname:port)

static Socket getSocket ( String  host,
int  port,
int  timeout 
) throws IOException [static, protected]

Method which gets a connection from SocketChannel.

Parameters:
host host to establish connection to
port port on that host
timeout connection timeout in ms
Returns:
connected socket
Exceptions:
IOException if errors connecting or if connection times out

int hashCode (  ) 

use the sockets hashcode for this object so we can key off of SockIOs

Returns:
int hashcode

boolean isAlive (  )  [package]

boolean isConnected (  )  [package]

checks if the connection is open

Returns:
true if connected

int read ( byte[]  b  )  throws IOException

reads length bytes into the passed in byte array from dtream

Parameters:
b byte array
Exceptions:
IOException if io problems during read

Implements LineInputStream.

String readLine (  )  throws IOException

reads a line intentionally not using the deprecated readLine method from DataInputStream

Returns:
String that was read in
Exceptions:
IOException if io problems during read

Implements LineInputStream.

String toString (  ) 

returns the string representation of this socket

Returns:
string

void trueClose ( boolean  addToDeadPool  )  throws IOException

closes socket and all streams connected to it

Exceptions:
IOException if fails to close streams or socket

void trueClose (  )  throws IOException

closes socket and all streams connected to it

Exceptions:
IOException if fails to close streams or socket

void write ( byte[]  b  )  throws IOException [package]

writes a byte array to the output stream

Parameters:
b byte array to write
Exceptions:
IOException if an io error happens


Member Data Documentation

String host [private]

DataInputStream in [private]

Logger log [static, private]

Initial value:

                        Logger.getLogger( SockIO.class.getName() )

BufferedOutputStream out [private]

SockIOPool pool [private]

Socket sock [private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:42:31 2012 for Project Wonder by  doxygen 1.5.8