public static class SockIOPool.SockIO extends java.lang.Object implements LineInputStream
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
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
|
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
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 socketjava.net.UnknownHostException
- if hostname is invalidpublic 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 socketjava.net.UnknownHostException
- if hostname is invalidprotected 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 msjava.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 socketpublic 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 LineInputStream
java.io.IOException
- if io problems during readpublic void clearEOL() throws java.io.IOException
clearEOL
in interface LineInputStream
java.io.IOException
- if io problems during readpublic int read(byte[] b) throws java.io.IOException
read
in interface LineInputStream
b
- byte arrayjava.io.IOException
- if io problems during readvoid flush() throws java.io.IOException
java.io.IOException
- if io problems during readvoid write(byte[] b) throws java.io.IOException
b
- byte array to writejava.io.IOException
- if an io error happenspublic int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
Copyright © 2005 - greg whalin