public abstract class AbstractSocketDriver extends AbstractDriver implements ExitCleaning, StreamIODriver
| Modifier and Type | Field and Description |
|---|---|
private static long |
DEFCLOSETIMEOUT
Defaults to no wait before closing.
|
private InputStream |
in
On open, the input stream opened.
|
static String |
KEY_CLOSETIMEOUT
Wait before close.
|
static String |
KEY_SOCKETPORT
Port of the server.
|
static String |
KEY_SOCKETSERVER
Key to the host.
|
static String |
KEY_SOCKETTIMEOUT
Timeout.
|
private OutputStream |
out
On open, the output stream opened.
|
private Socket |
socket
This is the connected socket.
|
KEY_DRIVERNAMEKEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATORCONFIG, KEY_CLASS| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSocketDriver(Map<String,String> prop)
Creates a new socket server.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
authenticate()
Authenticates at the remote host.
|
boolean |
close()
Disconnect from remote host.
|
void |
exit()
On exit we always close.
|
InputStream |
getInputStream()
Returns the input stream for this socket driver.
|
OutputStream |
getOutputStream()
Returns the output stream for this socket driver.
|
protected Socket |
getSocket()
Returns the socket.
|
void |
init()
On init, we check if we have all the required properties set.
|
boolean |
isOpen()
Returns true if the connection is open.
|
boolean |
open()
Connect to remote host.
|
void |
setTimeout(int mils)
Set default timeout for socket reads
|
createDriver, equals, getDriverName, hashCodeaugment, augment, augment, augment, augment, clone, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, initProperties, isNew, parseObject, parseObject, reload, reload, removeProperty, requires, rescanned, setObject, setProperties, setProperty, stringProperties, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitgetDriverNamepublic static final String KEY_SOCKETSERVER
public static final String KEY_SOCKETPORT
public static final String KEY_SOCKETTIMEOUT
public static final String KEY_CLOSETIMEOUT
private static final long DEFCLOSETIMEOUT
private Socket socket
private InputStream in
private OutputStream out
public void init()
init in interface Initializablepublic void exit()
exit in interface ExitCleaningpublic void setTimeout(int mils)
throws SocketException
mils - timeout in msec for socket readsSocketExceptionpublic boolean open()
throws IOException
open in interface DriverIOException - Exception to throw on connection errorprotected boolean authenticate()
throws IOException
IOExceptionpublic boolean isOpen()
public boolean close()
throws IOException
close in interface Driverforce - force a disconnect, even in persistent modeIOException - Exception to throw on disconnection errorpublic InputStream getInputStream()
getInputStream in interface StreamIODriverpublic OutputStream getOutputStream()
getOutputStream in interface StreamIODriverprotected Socket getSocket()