/*
 * @(#)Connection.java
 *
 * Copyright (c) 2002-2003 JSCAPE
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JSCAPE. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JSCAPE.
 */

/*
 * Classname: Connection
 *
 * Version: 1.0
 *
 * Author: Alex Usun
 */
package com.jscape.inet.util.connection;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * Abstract TCP connection.
 *
 * @author Alex Usun
 * @version 1.0
 */
public interface Connection {

    /**
     * Returns remote end address.
     *
     * @return remote end address
     */
    String getRemoteAddress();

    /**
     * Returns remote end port.
     *
     * @return remote rns port
     */
    int getRemotePort();

    /**
     * Returns local address.
     *
     * @return local address
     */
    String getLocalAddress();

    /**
     * Returns local port.
     *
     * @return local port
     */
    int getLocalPort();

    /**
     * Returns connection timeout.
     *
     * @return connection timeout
     *
     * @throws IOException if an error occurs
     */
    long getTimeout()
            throws IOException;

    /**
     * Setups connection timeout.
     *
     * @param timeout new timeout value
     *
     * @throws IOException if an error occurs
     */
    void setTimeout(long timeout)
            throws IOException;

    /**
     * Returns connection input stream.
     *
     * @return connection input stream
     *
     * @throws IOException if an I/O error occurs
     */
    InputStream getInputStream()
            throws IOException;

    /**
     * Returns connection output stream.
     *
     * @return connection output stream
     *
     * @throws IOException if an I/O error occurs
     */
    OutputStream getOutputStream()
            throws IOException;

    /**
     * Closes the current connection.
     */
    void close();

    /**
     * Checks if connection is already closed.
     *
     * @return <code>true</code> if connection is closed;
     *         <code>false</code> otherwise
     */
    boolean isClosed();

}
