EPP RTK
for Java v 0.7.2

com.tucows.oxrs.epp0604.rtk.transport
Class EPPTransportTCP

java.lang.Object
  |
  +--org.omg.CORBA.portable.ObjectImpl
        |
        +--com.tucows.oxrs.epp0604.rtk.RTKBase
              |
              +--com.tucows.oxrs.epp0604.rtk.transport.EPPTransportBase
                    |
                    +--com.tucows.oxrs.epp0604.rtk.transport.EPPTransportTCP
All Implemented Interfaces:
org.omg.CORBA.Object
Direct Known Subclasses:
EPPTransportTCPTLS

public class EPPTransportTCP
extends EPPTransportBase

Provides methods necessary to establish connection and to communicate with an EPP Server using plain socket (no encryption).


Field Summary
protected static int INT_SZ
           
protected  boolean preset_
          Flag to indicate if the transports socket has been preset externally.
protected  java.io.BufferedInputStream reader_from_server_
          Input stream from the server.
protected  java.net.Socket socket_to_server_
          The socket to the server.
protected  java.io.BufferedOutputStream writer_to_server_
          Output stream to the server.
 
Fields inherited from class com.tucows.oxrs.epp0604.rtk.transport.EPPTransportBase
DEFAULT_SOCKET_TIMEOUT, epp_host_name_, epp_host_port_, epp_timeout_
 
Fields inherited from class com.tucows.oxrs.epp0604.rtk.RTKBase
CRLF, DATE_FMT, DEBUG_LEVEL_ONE, DEBUG_LEVEL_THREE, DEBUG_LEVEL_TWO, DEBUG_NONE, RTK_VERSION, UTC_FMT
 
Constructor Summary
EPPTransportTCP()
          Default Construtor
EPPTransportTCP(java.net.Socket socket, int timeout)
          Construtor with established socket and timeout value If the timeout value is zero, the default timeout value from EPPTransportBase is used.
EPPTransportTCP(java.lang.String host_name, int host_port, int timeout)
          Construtor with Hostname, Host port and timeout value If the timeout value is zero, the default timeout value from EPPTransportBase is used.
 
Method Summary
 void connect()
          Connects to the Server using previously set Hostname and port.
 void disconnect()
          Closes the connection to the Server
protected  int readBufferSize(java.io.BufferedInputStream in)
          Reads 4 bytes and converts them into an integer
 java.lang.String readFromServer()
          Reads a complete XML message from the Server.
protected  byte[] readInputBuffer(java.io.BufferedInputStream in, int inbuf_sz)
          Reads inbuf_sz number of bytes from the socket
protected  void writeBufferSize(java.io.BufferedOutputStream out, int buf_sz)
          Converts integer value into 4 bytes and writes the bytes into a socket
 void writeToServer(java.lang.String xml_to_server)
          Sends an XML string to the Server
 
Methods inherited from class com.tucows.oxrs.epp0604.rtk.transport.EPPTransportBase
getEPPHostName, getEPPHostPort, getEPPTimeout, initialize, setEPPHostName, setEPPHostPort, setEPPTimeout
 
Methods inherited from class com.tucows.oxrs.epp0604.rtk.RTKBase
_ids, debug, debug, getDebugLevel, getDebugPrintStream, getRTKProperties, setDebugLevel, setDebugLevel, setDebugPrintStream
 
Methods inherited from class org.omg.CORBA.portable.ObjectImpl
_create_request, _create_request, _duplicate, _get_delegate, _get_domain_managers, _get_interface_def, _get_policy, _hash, _invoke, _is_a, _is_equivalent, _is_local, _non_existent, _orb, _release, _releaseReply, _request, _request, _servant_postinvoke, _servant_preinvoke, _set_delegate, _set_policy_override, equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

socket_to_server_

protected java.net.Socket socket_to_server_
The socket to the server.


reader_from_server_

protected java.io.BufferedInputStream reader_from_server_
Input stream from the server. Begotten from the socket.


writer_to_server_

protected java.io.BufferedOutputStream writer_to_server_
Output stream to the server. Begotten from the socket.


preset_

protected boolean preset_
Flag to indicate if the transports socket has been preset externally.


INT_SZ

protected static final int INT_SZ
See Also:
Constant Field Values
Constructor Detail

EPPTransportTCP

public EPPTransportTCP()
Default Construtor


EPPTransportTCP

public EPPTransportTCP(java.net.Socket socket,
                       int timeout)
Construtor with established socket and timeout value If the timeout value is zero, the default timeout value from EPPTransportBase is used.

Parameters:
socket - The Socket to the server
timeout - The int socket timeout value, in milliseconds

EPPTransportTCP

public EPPTransportTCP(java.lang.String host_name,
                       int host_port,
                       int timeout)
Construtor with Hostname, Host port and timeout value If the timeout value is zero, the default timeout value from EPPTransportBase is used.

Parameters:
host_name - The server Hostname
host_port - The server Host port
timeout - The int socket timeout value, in milliseconds
Method Detail

connect

public void connect()
             throws java.net.SocketException,
                    java.io.IOException,
                    java.net.UnknownHostException
Connects to the Server using previously set Hostname and port. If the socket was provided externally, the connection operation is skipped, but the input and output buffers are still extracted. The method also sets the SO timeout of the socket regardless of its origins.

Specified by:
connect in class EPPTransportBase
Throws:
java.net.UnknownHostException
java.io.IOException
java.net.SocketException

readFromServer

public java.lang.String readFromServer()
                                throws epp_Exception
Reads a complete XML message from the Server.

Specified by:
readFromServer in class EPPTransportBase
Returns:
Full XML String
Throws:
epp_Exception - if there was a socket error in reading from the EPP Server
See Also:
epp_Session.RTK_COMMUNICATIONS_FAILURE, epp_Session.RTK_UNEXPECTED_SERVER_DISCONNECT

writeToServer

public void writeToServer(java.lang.String xml_to_server)
                   throws epp_Exception
Sends an XML string to the Server

Specified by:
writeToServer in class EPPTransportBase
Parameters:
xml_to_server - The EPP message to the server.
Throws:
epp_Exception - if there was a socket error in writing to the EPP Server. The epp_Exception will contain a result with the code epp_Session.RTK_COMMUNICATIONS_FAILURE
See Also:
epp_Session.RTK_COMMUNICATIONS_FAILURE

disconnect

public void disconnect()
                throws java.io.IOException
Closes the connection to the Server

Specified by:
disconnect in class EPPTransportBase
Throws:
java.io.IOException - if there was a Socket problem

readBufferSize

protected int readBufferSize(java.io.BufferedInputStream in)
                      throws java.lang.Exception
Reads 4 bytes and converts them into an integer

Returns:
length of the XML instance and header
Throws:
java.lang.Exception - if there was a Socket problem or less than 4 bytes read

readInputBuffer

protected byte[] readInputBuffer(java.io.BufferedInputStream in,
                                 int inbuf_sz)
                          throws java.lang.Exception
Reads inbuf_sz number of bytes from the socket

Returns:
bytes read
Throws:
java.lang.Exception - if there was a Socket problem

writeBufferSize

protected void writeBufferSize(java.io.BufferedOutputStream out,
                               int buf_sz)
                        throws java.io.IOException
Converts integer value into 4 bytes and writes the bytes into a socket

Throws:
java.io.IOException - if there was a Socket problem

EPP RTK
for Java v 0.7.2

Copyright ? 2001-2002 - Tucows, Inc., 2003 - LibertyRMS