com.ibm.etill.framework.io
Class SyncSocketComPoint
java.lang.Object
|
+--com.ibm.etill.framework.io.SocketComPoint
|
+--com.ibm.etill.framework.io.SyncSocketComPoint
- All Implemented Interfaces:
- ComPoint
- public abstract class SyncSocketComPoint
- extends SocketComPoint
This is an abstract client ComPoint class for synchronous Socket based
communications. This class instantiates Socket objects to generate socket
connections to a specified host.
The class is used to create concrete classes that establish connections
for specific ETillConnection objects. Thus, a concrete class need only
override the establishConnection() method.
In a multithreaded environment this class makes sure that only
a certain number of connections are open at the same time. If more
threads want to connect they have to wait until a Socket becomes
available. All the methods of this class are synchronized to make sure
that only one thread a a time can change something.
Each time a thread asks for a new connection (when calling getSocket()
and it is authorized by this class, it receives a Socket.
The thread can then use the Socket to write, read and close a
connection via an ETillConnection. When it is done, the thread must call
releaseSocket() to notify SyncSocketComPoint that a connection is available
for a new thread.
Constructor Summary |
SyncSocketComPoint(String host,
int portNumber,
int maxConnections,
int timeOut)
This Constructor stores a reference of the hostname and the port number
used by this SyncSocketComPoint when creating a Socket. |
Method Summary |
int |
getTimeout()
getTimeout() -- return the timeout value (in milliseconds) |
void |
releaseConnection()
When a Socket is released (via ETillConnection.closeConnection()
this method must be called to notify the
class that a Socket is available. |
void |
setTimeout(int timeOut)
setTimeout() -- set timeout value (in milliseconds) |
String |
toString()
toString() -- converts an ServerSocketComPoint into a printable string |
SyncSocketComPoint
public SyncSocketComPoint(String host,
int portNumber,
int maxConnections,
int timeOut)
- This Constructor stores a reference of the hostname and the port number
used by this SyncSocketComPoint when creating a Socket.
- Parameters:
hostname
- The hostname to connect toport
- The port number to connect tomaxConnections
- the maximum number of Socket that this class
can return, this is also the maximum number of
connections that can be open at the same time
toString
public String toString()
- toString() -- converts an ServerSocketComPoint into a printable string
- Overrides:
toString
in class SocketComPoint
- Following copied from class:
com.ibm.etill.framework.io.SocketComPoint
- Returns:
- A String representation of the class
setTimeout
public void setTimeout(int timeOut)
- setTimeout() -- set timeout value (in milliseconds)
getTimeout
public int getTimeout()
- getTimeout() -- return the timeout value (in milliseconds)
releaseConnection
public void releaseConnection()
- When a Socket is released (via ETillConnection.closeConnection()
this method must be called to notify the
class that a Socket is available.