public static class SchoonerSockIOPool.TCPSockIO extends SchoonerSockIO
| Modifier and Type | Field and Description |
|---|---|
SocketChannel |
sockChannel |
readBuf, sockets, writeBuf| Constructor and Description |
|---|
SchoonerSockIOPool.TCPSockIO(org.apache.commons.pool.impl.GenericObjectPool sockets,
String host,
int bufferSize,
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
|
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.
|
void |
flush()
writes data stored in writeBuf to server
|
ByteChannel |
getByteChannel()
get byte channel from this socket.
|
SocketChannel |
getChannel()
Lets caller get access to underlying channel.
|
String |
getHost()
returns the host this socket is connected to
|
byte[] |
getResponse(short rid) |
protected static Socket |
getSocket(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
|
boolean |
isConnected()
checks if the connection is open
|
short |
preWrite() |
int |
read(byte[] b)
reads length bytes into the passed in byte array from dtream
|
void |
readBytes(int length)
read fix length data from server and store it in the readBuf
|
String |
readLine()
reads a line intentionally not using the deprecated readLine method
from DataInputStream
|
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
|
void |
write(byte[] b)
writes a byte array to the output stream
|
getBufferSize, isAlive, setBufferSizepublic SocketChannel sockChannel
public SchoonerSockIOPool.TCPSockIO(org.apache.commons.pool.impl.GenericObjectPool sockets,
String host,
int bufferSize,
int timeout,
int connectTimeout,
boolean noDelay)
throws IOException,
UnknownHostException
host - hostname:porttimeout - read timeout value for connected socketconnectTimeout - timeout for initial connectionsnoDelay - TCP NODELAY option?IOException - if an io error occurrs when creating socketUnknownHostException - if hostname is invalidprotected static final Socket getSocket(String host, int port, int timeout) throws IOException
host - host to establish connection toport - port on that hosttimeout - connection timeout in msIOException - if errors connecting or if connection times outpublic final SocketChannel getChannel()
getChannel in class SockIOPool.SockIOpublic final String getHost()
getHost in class SockIOPool.SockIOpublic final void trueClose()
throws IOException
trueClose in class SockIOPool.SockIOIOException - if fails to close streams or socketpublic final void close()
close in class SockIOPool.SockIOpublic boolean isConnected()
isConnected in class SockIOPool.SockIOpublic final void readBytes(int length)
throws IOException
length - data lengthIOException - if an io error happenspublic void write(byte[] b)
throws IOException
write in class SockIOPool.SockIOb - byte array to writeIOException - if an io error happenspublic void flush()
throws IOException
flush in class SockIOPool.SockIOIOException - if an io error happenspublic final int hashCode()
hashCode in class SockIOPool.SockIOpublic final String toString()
toString in class SockIOPool.SockIOprotected final void finalize()
throws Throwable
finalize in class SockIOPool.SockIOThrowablepublic short preWrite()
preWrite in class SchoonerSockIOpublic byte[] getResponse(short rid)
throws IOException
getResponse in class SchoonerSockIOIOExceptionpublic void clearEOL()
throws IOException
SockIOPool.SockIOclearEOL in interface LineInputStreamclearEOL in class SockIOPool.SockIOIOException - if io problems during readpublic int read(byte[] b)
throws IOException
SockIOPool.SockIOread in interface LineInputStreamread in class SockIOPool.SockIOb - byte arrayIOException - if io problems during readpublic String readLine() throws IOException
SockIOPool.SockIOreadLine in interface LineInputStreamreadLine in class SockIOPool.SockIOIOException - if io problems during readpublic void trueClose(boolean addToDeadPool)
throws IOException
SockIOPool.SockIOtrueClose in class SockIOPool.SockIOIOException - if fails to close streams or socketpublic ByteChannel getByteChannel()
SchoonerSockIOgetByteChannel in class SchoonerSockIOCopyright © 2013 Schooner Information Technology. All Rights Reserved.