EPPTransportTCP (EPP RTK Java API Documentation)
Keywords: com.tucows.oxrs.epp0705.rtk.transport.EPPTransportTCP class

### com.tucows.oxrs.epp0705.rtk.transport

# Class EPPTransportTCP

- `org.omg.CORBA.portable.ObjectImpl`
- - `com.tucows.oxrs.epp0705.rtk.RTKBase`
  - - `com.tucows.oxrs.epp0705.rtk.transport.EPPTransportBase`
    - - `com.tucows.oxrs.epp0705.rtk.transport.EPPTransportTCP`

Known Direct 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 BufferedInputStream` | `reader_from_server_` Input stream from the server.
  `protected Socket` | `socket_to_server_` The socket to the server.
  `protected BufferedOutputStream` | `writer_to_server_` Output stream to the server.

  ### Fields inherited from class com.tucows.oxrs.epp0705.rtk.transport.EPPTransportBase
  `DEFAULT_SOCKET_TIMEOUT`, `epp_host_name_`, `epp_host_port_`, `epp_timeout_`

  ### Fields inherited from class com.tucows.oxrs.epp0705.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(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(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(BufferedInputStream in)` Reads 4 bytes and converts them into an integer
  `String` | `readFromServer()` Reads a complete XML message from the Server.
  `protected byte[]` | `readInputBuffer(BufferedInputStream in, int inbuf_sz)` Reads inbuf_sz number of bytes from the socket
  `protected void` | `writeBufferSize(BufferedOutputStream out, int buf_sz)` Converts integer value into 4 bytes and writes the bytes into a socket
  `void` | `writeToServer(String xml_to_server)` Sends an XML string to the Server

  ### Methods inherited from class com.tucows.oxrs.epp0705.rtk.transport.EPPTransportBase
  `connect`, `disconnect`, `getEPPHostName`, `getEPPHostPort`, `getEPPTimeout`, `initialize`, `readFromServer`, `setEPPHostName`, `setEPPHostPort`, `setEPPTimeout`, `writeToServer`

  ### Methods inherited from class com.tucows.oxrs.epp0705.rtk.RTKBase
  `_ids`, `debug`, `debug`, `getDebugLevel`, `getDebugPrintStream`, `getEasyProperty`, `getRTKProperties`, `setDebugLevel`, `setDebugLevel`, `setDebugPrintStream`

## Field Details

### INT_SZ

    protected static final int INT_SZ

> Field Value:
>   4

### preset_

    protected boolean preset_

> Flag to indicate if the transports socket has been preset externally.

### reader_from_server_

    protected BufferedInputStream reader_from_server_

> Input stream from the server. Begotten from the socket.

### socket_to_server_

    protected Socket socket_to_server_

> The socket to the server.

### writer_to_server_

    protected BufferedOutputStream writer_to_server_

> Output stream to the server. Begotten from the socket.

## Constructor Details

### EPPTransportTCP

    public EPPTransportTCP()

> Default Construtor

### EPPTransportTCP

    public EPPTransportTCP(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(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 Details

### connect

    public void connect()
                throws SocketException,
                       IOException,
                       UnknownHostException,
                       EPPTransportException

> 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.
> Overrides:
>   connect in interface EPPTransportBase

### disconnect

    public void disconnect()
                throws IOException

> Closes the connection to the Server
> Overrides:
>   disconnect in interface EPPTransportBase

### readBufferSize

    protected int readBufferSize(BufferedInputStream in)
                throws Exception

> Reads 4 bytes and converts them into an integer
> Returns:
>   length of the XML instance and header

### readFromServer

    public String readFromServer()
                throws epp_Exception

> Reads a complete XML message from the Server.
> Overrides:
>   readFromServer in interface 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`

### readInputBuffer

    protected byte[] readInputBuffer(BufferedInputStream in,
                                     int inbuf_sz)
                throws Exception

> Reads inbuf_sz number of bytes from the socket
> Returns:
>   bytes read

### writeBufferSize

    protected void writeBufferSize(BufferedOutputStream out,
                                   int buf_sz)
                throws IOException

> Converts integer value into 4 bytes and writes the bytes into a socket

### writeToServer

    public void writeToServer(String xml_to_server)
                throws epp_Exception

> Sends an XML string to the Server
> Overrides:
>   writeToServer in interface EPPTransportBase
> 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`

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