fr.ove.utils
Class Connection

java.lang.Object
  extended byfr.ove.utils.Connection
All Implemented Interfaces:
ConnectionConfigurable

public class Connection
extends java.lang.Object
implements ConnectionConfigurable

A connection object. Opens a socket to the specified host on the specified port number.


Constructor Summary
Connection()
          The default constructor.
Connection(java.lang.String hostName, int portNumber)
          The Constructor.
 
Method Summary
 void close()
          Closes the connection.
 java.lang.String getHostName()
          Returns the host name for the connection to create.
 java.io.InputStream getInputStream()
          Gets the input stream to read from the socket.
 java.io.OutputStream getOutputStream()
          Gets the output stream to write into the socket.
 int getPortNumber()
          Returns the port number for the connexion to create.
 boolean isOpened()
          Checks wether the connection is opened.
 void open()
          Opens the connection.
 void open(java.net.Socket socket)
          Opens the connection through the specified socket.
 void setHostName(java.lang.String name)
          Sets the host name for the connection to create.
 void setPortNumber(int number)
          Sets the port number for the connexion to create.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Connection

public Connection()
The default constructor. The default host name is "localhost" and the default port number is 6666.


Connection

public Connection(java.lang.String hostName,
                  int portNumber)
The Constructor.

Parameters:
hostName - the host name.
portNumber - the port number.
Method Detail

setHostName

public void setHostName(java.lang.String name)
Sets the host name for the connection to create.

Specified by:
setHostName in interface ConnectionConfigurable
Parameters:
name - the host name.

getHostName

public java.lang.String getHostName()
Returns the host name for the connection to create.

Specified by:
getHostName in interface ConnectionConfigurable

setPortNumber

public void setPortNumber(int number)
Sets the port number for the connexion to create.

Specified by:
setPortNumber in interface ConnectionConfigurable
Parameters:
number - the port number.

getPortNumber

public int getPortNumber()
Returns the port number for the connexion to create.

Specified by:
getPortNumber in interface ConnectionConfigurable

open

public void open()
          throws java.io.IOException
Opens the connection.

Throws:
java.io.IOException

open

public void open(java.net.Socket socket)
          throws java.io.IOException
Opens the connection through the specified socket.

Parameters:
socket - the specified socket.
Throws:
java.io.IOException

isOpened

public boolean isOpened()
Checks wether the connection is opened.


close

public void close()
           throws java.io.IOException
Closes the connection.

Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
Gets the input stream to read from the socket.


getOutputStream

public java.io.OutputStream getOutputStream()
Gets the output stream to write into the socket.



Copyright © 1999-2007 Universit?© de Nice Sophia-Antipolis, I3S, Ove SARL, DFKI and Universit?§t des Saarlandes. All Rights Reserved.