|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectits.element.ClientConnection
Creates and monitors a client socket for reading ITS Frames. The socket is connected to a server and attempts to reconnect are made if the connection is broken.
The connection is considered to be broken if any socket exceptions are thrown during a read, or if an excessive time passes without receiving any data. This timeout value is 3 minutes by default.
If a connection attempt fails, there is a pause before the next attempt. The length of the pause starts at one second and doubles with each successive attempt before reaching a maximum of 64 seconds. A limit may be set on the number of unsuccessful reconnection attempts, but by default there is no limit.
| Constructor Summary | |
ClientConnection(java.net.InetAddress host,
int port)
Creates connection given the address and port of the server |
|
ClientConnection(java.lang.String host,
int port)
Creates connection given a hostname and a port. |
|
| Method Summary | |
void |
close()
Closes input stream and underlying client socket. |
void |
connect()
Connect to server. |
protected void |
finalize()
calls close to clean up the socket and stream |
int |
getInitialBackoff()
|
int |
getMaxAttempt()
|
int |
getMaxBackoff()
|
int |
getTimeout()
|
ItsFrame |
read()
Reads an ITS frame from the server. |
void |
setInitialBackoff(int newBackoff)
sets initialBackoff, the pause between the first two connection retries. |
void |
setMaxAttempt(int newMax)
set the maximum number of connect attempts to be made. |
void |
setMaxBackoff(int newBackoff)
sets maxBackoff, the maximum pause between connection attempts. |
void |
setServerPort(int port)
|
void |
setTimeout(int newTimeout)
sets receive timeout. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ClientConnection(java.net.InetAddress host,
int port)
throws java.io.IOException
host - the server addressport - the server port number
java.io.IOException - if a connection to the given server is impossible
public ClientConnection(java.lang.String host,
int port)
throws java.io.IOException
host - the server nameport - the server port number
java.io.IOException - if a connection to the given server is impossible| Method Detail |
public void connect()
throws ItsException
ItsException - thrown when too many reconnection attempts have been made
public ItsFrame read()
throws ItsException
ItsException - thrown when too many reconnection attempts have been madepublic void close()
public void setMaxAttempt(int newMax)
public int getMaxAttempt()
public int getInitialBackoff()
public void setInitialBackoff(int newBackoff)
newBackoff - the new initial backoff between connection attempts
in milliseconds. This must be >= 1.public void setMaxBackoff(int newBackoff)
newBackoff - the new maximum backoff between connection attempts.
This must be >= initialBackoff.public int getMaxBackoff()
public void setTimeout(int newTimeout)
newTimeout - the new receive timeout in milliseconds. A value
of 0 disables the timeout and a read will block forever.public int getTimeout()
public void setServerPort(int port)
protected void finalize()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||