Back to index

wims  3.65+svn20090927
Public Member Functions | Private Attributes
fr.ove.utils.Connection Class Reference

A connection object. More...

Inheritance diagram for fr.ove.utils.Connection:
Inheritance graph
[legend]
Collaboration diagram for fr.ove.utils.Connection:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Connection ()
 The default constructor.
 Connection (String hostName, int portNumber)
 The Constructor.
void setHostName (String name)
 Sets the host name for the connection to create.
String getHostName ()
 Returns the host name for the connection to create.
void setPortNumber (int number)
 Sets the port number for the connexion to create.
int getPortNumber ()
 Returns the port number for the connexion to create.
void open () throws IOException
 Opens the connection.
void open (Socket socket) throws IOException
 Opens the connection through the specified socket.
boolean isOpened ()
 Checks wether the connection is opened.
void close () throws IOException
 Closes the connection.
InputStream getInputStream ()
 Gets the input stream to read from the socket.
OutputStream getOutputStream ()
 Gets the output stream to write into the socket.

Private Attributes

Socket socket
 The socket of the connection.
InputStream inputStream = null
 The input stream to read from the socket.
OutputStream outputStream = null
 The output stream to write into the socket.
String hostName
 The host name to connect.
int portNumber
 The port number.

Detailed Description

A connection object.

Opens a socket to the specified host on the specified port number.

Definition at line 15 of file Connection.java.


Constructor & Destructor Documentation

The default constructor.

The default host name is "localhost" and the default port number is 6666.

Definition at line 45 of file Connection.java.

                        {
        this("localhost", 6666);
    }
fr.ove.utils.Connection.Connection ( String  hostName,
int  portNumber 
) [inline]

The Constructor.

Parameters:
hostNamethe host name.
portNumberthe port number.

Definition at line 54 of file Connection.java.

                                                       {
        this.hostName = hostName;
        this.portNumber = portNumber;
    }

Member Function Documentation

void fr.ove.utils.Connection.close ( ) throws IOException [inline]

Closes the connection.

Definition at line 120 of file Connection.java.

                                           {
        outputStream.close();
        inputStream.close();
        outputStream = null;
        inputStream = null;
    }

Returns the host name for the connection to create.

Implements fr.ove.utils.ConnectionConfigurable.

Definition at line 70 of file Connection.java.

                                {
        return hostName;
    }
InputStream fr.ove.utils.Connection.getInputStream ( ) [inline]

Gets the input stream to read from the socket.

Definition at line 130 of file Connection.java.

                                        {
        return inputStream;
    }
OutputStream fr.ove.utils.Connection.getOutputStream ( ) [inline]

Gets the output stream to write into the socket.

Definition at line 137 of file Connection.java.

                                          {
        return outputStream;
    }

Returns the port number for the connexion to create.

Implements fr.ove.utils.ConnectionConfigurable.

Definition at line 85 of file Connection.java.

                               {
        return portNumber;
    }

Checks wether the connection is opened.

Definition at line 113 of file Connection.java.

                              {
        return ((outputStream != null) && (inputStream != null));
    }
void fr.ove.utils.Connection.open ( ) throws IOException [inline]

Opens the connection.

Definition at line 92 of file Connection.java.

                                          {
              socket = new Socket(InetAddress.getByName(hostName), portNumber);
              inputStream = socket.getInputStream();
              outputStream = socket.getOutputStream();
    }
void fr.ove.utils.Connection.open ( Socket  socket) throws IOException [inline]

Opens the connection through the specified socket.

Parameters:
socketthe specified socket.

Definition at line 102 of file Connection.java.

                                                       {
              this.socket = socket;
              hostName = socket.getInetAddress().getHostName();
              portNumber = socket.getPort();
              inputStream = socket.getInputStream();
              outputStream = socket.getOutputStream();
    }
void fr.ove.utils.Connection.setHostName ( String  name) [inline]

Sets the host name for the connection to create.

Parameters:
namethe host name.

Implements fr.ove.utils.ConnectionConfigurable.

Definition at line 63 of file Connection.java.

                                         {
        hostName = name;
    }
void fr.ove.utils.Connection.setPortNumber ( int  number) [inline]

Sets the port number for the connexion to create.

Parameters:
numberthe port number.

Implements fr.ove.utils.ConnectionConfigurable.

Definition at line 78 of file Connection.java.

                                          {
        portNumber = number;
    }

Member Data Documentation

The host name to connect.

Definition at line 34 of file Connection.java.

InputStream fr.ove.utils.Connection.inputStream = null [private]

The input stream to read from the socket.

Definition at line 24 of file Connection.java.

OutputStream fr.ove.utils.Connection.outputStream = null [private]

The output stream to write into the socket.

Definition at line 29 of file Connection.java.

The port number.

Definition at line 39 of file Connection.java.

The socket of the connection.

Definition at line 19 of file Connection.java.


The documentation for this class was generated from the following file: