Open SiteSearch 4.1.1
Final

ORG.oclc.ber
Class BerConnect

java.lang.Object
  |
  +--ORG.oclc.ber.BerConnect

public class BerConnect
extends Object

BerConnect handles the I/0 between a client and a server passing BerEncoded messages.


Constructor Summary
BerConnect(String hostname, int port)
          Construct a connection object for the input host and port.
BerConnect(String hostname, int port, boolean useConnectTimeout)
          Construct a connection object for the input host, port and flag indicating whether the socket connect should be timed.
BerConnect(String hostname, int port, int readTimeout)
          Construct a connection object for the input host, port and read timeout.
BerConnect(String hostname, int port, int readTimeout, boolean useConnectTimeout)
          Construct a connection object for the input host, port, read timeout, and flag indicating whether the socket connect should be timed.
 
Method Summary
 void close()
          Closes the socket connection.
 Socket connection()
           
 BerString doRequest(BerString request)
          Send a request.
 BerString doRequest(BerString request, boolean yieldFlag)
          Send a request.
 BerString doRequest(BerString request, String hostname, int port)
          Send a request.
 boolean sendRequest(BerString request)
          Send a request.
 void setRetryCount(int counter)
          Sets the retry count on the number of times to try to send a message where the default = 2.
 void setTimeout(int timeout)
          Sets the read Timeout on the socket to the input number of seconds.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BerConnect

public BerConnect(String hostname,
                  int port)
           throws UnknownHostException,
                  IOException
Construct a connection object for the input host and port.
Parameters:
hostname - the name of the host
port - the port to connect to

BerConnect

public BerConnect(String hostname,
                  int port,
                  int readTimeout)
           throws UnknownHostException,
                  IOException
Construct a connection object for the input host, port and read timeout.
Parameters:
hostname - the name of the host
port - the port to connect to
readTimeout - the number of seconds to wait for a read response

BerConnect

public BerConnect(String hostname,
                  int port,
                  boolean useConnectTimeout)
           throws UnknownHostException,
                  IOException
Construct a connection object for the input host, port and flag indicating whether the socket connect should be timed.
Parameters:
hostname - the name of the host
port - the port to connect to
useConnectTimeout - flag to indicate whether the connect request should be timed.

BerConnect

public BerConnect(String hostname,
                  int port,
                  int readTimeout,
                  boolean useConnectTimeout)
           throws UnknownHostException,
                  IOException
Construct a connection object for the input host, port, read timeout, and flag indicating whether the socket connect should be timed.
Parameters:
hostname - the name of the host
port - the port to connect to
readTimeout - the number of seconds to wait for a read response
useConnectTimeout - flag to indicate whether the connect request should be timed.
Method Detail

toString

public String toString()
Overrides:
toString in class Object

doRequest

public BerString doRequest(BerString request,
                           String hostname,
                           int port)
                    throws UnknownHostException,
                           EOFException,
                           FileNotFoundException,
                           IOException,
                           InterruptedIOException
Send a request. If the socket connection fails, re-connect to hostname and port. Return a response
Parameters:
request - a Ber encoded message
hostname - save this hostname for re-connects
port - save this port for re-connects
Returns:
a Ber encoded Response
Throws:
UnknownHostException - the server cannot be located
EOFException - the server is unavailable
FileNotFoundException - the server is unavailable
IOException - the server is unavailable

doRequest

public BerString doRequest(BerString request)
                    throws UnknownHostException,
                           EOFException,
                           FileNotFoundException,
                           IOException,
                           InterruptedIOException
Send a request. If the socket connection fails, re-connect to the last specified hostname and port. Return a response
Parameters:
request - a Ber encoded request
Returns:
Ber encoded Response
Throws:
UnknownHostException - the server cannot be located
EOFException - the server is unavailable
FileNotFoundException - the server is unavailable
IOException - the server is unavailable

doRequest

public BerString doRequest(BerString request,
                           boolean yieldFlag)
                    throws UnknownHostException,
                           EOFException,
                           FileNotFoundException,
                           IOException,
                           InterruptedIOException
Send a request. If the socket connection fails, re-connect to the last specified hostname and port. Return a response
Parameters:
request - a Ber encoded request
yieldFlag - a boolean indicating whether to yield before reading response
Returns:
Ber encoded Response
Throws:
UnknownHostException - the server cannot be located
EOFException - the server is unavailable
FileNotFoundException - the server is unavailable
IOException - the server is unavailable

sendRequest

public boolean sendRequest(BerString request)
                    throws UnknownHostException,
                           EOFException,
                           FileNotFoundException,
                           IOException
Send a request. If the socket connection fails, re-connect to the last specified hostname and port. This method should ONLY be used when a response is not expected from the server. When a response is expected, use the doRequest method.
Parameters:
request - Ber encoded request
Returns:
true if write succeeded
Throws:
UnknownHostException - the server cannot be located
EOFException - the server is unavailable
FileNotFoundException - the server is unavailable
IOException - the server is unavailable

close

public void close()
           throws IOException
Closes the socket connection.

setTimeout

public void setTimeout(int timeout)
Sets the read Timeout on the socket to the input number of seconds.
Parameters:
timeout - the number of seconds to wait on a response from a request.

setRetryCount

public void setRetryCount(int counter)
Sets the retry count on the number of times to try to send a message where the default = 2.
Parameters:
counter - the number of times to try sending the message before giving up.

connection

public Socket connection()
Returns:
the connection

Open SiteSearch 4.1.1
Final