public class SocketCommandClient
extends java.lang.Object
CommandInterpreter
Constructor and Description |
---|
SocketCommandClient()
Creats a SocketCommandClient with no connection open must be called.
|
SocketCommandClient(java.lang.String host,
int port)
Creates a socket command client at the given host and port.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the socket connection
|
java.lang.String |
getResponse()
Gets a response
|
int |
getSoTimeout() |
boolean |
isResponse()
is a response
|
static void |
main(java.lang.String[] args) |
void |
open(java.lang.String aHost,
int aPort)
Opens a socket connection
|
boolean |
sendCommand(java.lang.String command)
sends a command, retries on error which will attempt to repair a dead socket
|
java.lang.String |
sendCommandGetResponse(java.lang.String command)
sends a command get a response
|
void |
setSoTimeout(int millisecs)
Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
|
public SocketCommandClient(java.lang.String host, int port) throws java.io.IOException
host
- the host machineport
- the port to usejava.io.IOException
- if setup went wrongpublic SocketCommandClient()
public void open(java.lang.String aHost, int aPort) throws java.io.IOException
aHost
- the host to connect toaPort
- the port to connect tojava.io.IOException
- if connection failspublic int getSoTimeout() throws java.net.SocketException
java.net.SocketException
- if configuration failedpublic void setSoTimeout(int millisecs) throws java.net.SocketException
millisecs
- the timeout in millisecondsjava.net.SocketException
- if configuration failedpublic boolean sendCommand(java.lang.String command)
command
- the commandpublic java.lang.String getResponse()
public boolean isResponse()
public java.lang.String sendCommandGetResponse(java.lang.String command)
command
- the command to sendpublic void close()
public static void main(java.lang.String[] args)