public static class SockIOPool.SockIO extends Object implements LineInputStream
| Constructor and Description |
|---|
SockIOPool.SockIO(SockIOPool pool,
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,
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
|
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()
flushes output stream
|
SocketChannel |
getChannel()
Lets caller get access to underlying channel.
|
String |
getHost()
returns the host this socket is connected to
|
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 |
isAlive() |
protected boolean |
isConnected()
checks if the connection is open
|
int |
read(byte[] b)
reads length bytes into the passed in byte array from dtream
|
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
|
public SockIOPool.SockIO(SockIOPool pool, String host, int port, int timeout, int connectTimeout, boolean noDelay) throws IOException, 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?IOException - if an io error occurrs when creating socketUnknownHostException - if hostname is invalidpublic SockIOPool.SockIO(SockIOPool pool, String host, 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 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 SocketChannel getChannel()
public String getHost()
public void trueClose()
throws IOException
IOException - if fails to close streams or socketpublic void trueClose(boolean addToDeadPool)
throws IOException
IOException - if fails to close streams or socketpublic void close()
protected boolean isConnected()
public boolean isAlive()
public String readLine() throws IOException
readLine in interface LineInputStreamIOException - if io problems during readpublic void clearEOL()
throws IOException
clearEOL in interface LineInputStreamIOException - if io problems during readpublic int read(byte[] b)
throws IOException
read in interface LineInputStreamb - byte arrayIOException - if io problems during readpublic void flush()
throws IOException
IOException - if io problems during readpublic void write(byte[] b)
throws IOException
b - byte array to writeIOException - if an io error happenspublic int hashCode()
public String toString()
Copyright © 2013 Schooner Information Technology. All Rights Reserved.