Open SiteSearch 4.1.1
Final

ORG.oclc.sip
Class SipConnect

java.lang.Object
  |
  +--ORG.oclc.sip.SipConnect

public class SipConnect
extends Object

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


Constructor Summary
SipConnect(String hostname, int port)
          Construct a connection object.
SipConnect(String hostname, int port, int readTimeout)
          Construct a connection object.
 
Method Summary
 void close()
          Closes the socket connection.
 Socket connection()
           
 String doRequest(String request)
          Send a request.
 String doRequest(String request, boolean yieldFlag)
          Send a request.
 String doRequest(String request, String hostname, int port)
          Send a request.
 boolean sendRequest(String 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

SipConnect

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

SipConnect

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

toString

public String toString()
Overrides:
toString in class Object

doRequest

public String doRequest(String 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 String doRequest(String 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 String doRequest(String 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(String 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