Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

Cabal::Connection Class Reference

Encapsulates an high level abstract connection between this machine and a remote address. More...

#include <cabal_conn.h>

Collaboration diagram for Cabal::Connection:

Collaboration graph
List of all members.

Public Member Functions

 Connection (Socket *s, Transmission *trans, Reception *recpt=0)
 Creates a Connection.

 ~Connection ()
 Connection destructor.

void account (const int iBytes)
 Accounts transmission of bytes on this connection.

Socketsocket () const
 Retreives the socket used by this connection.

Address const & remote () const
 Retreives the remote address of this connection.

Lineline () const
 Retreives the Line that is owning this Connection.

void line (Line *l)
 Sets working line.

Transmission * transmission () const
 Retreives the transmission that is held in this connection.

Reception * reception () const
 Retreives the reception that is held in this connection.

void schedule (const long int milliseconds, Priority prio=medium_prio)
 Scedule after a certain time in milliseconds.

long int nextSchedule () const
 Return the moment in which this connection wants to be called again in milliseconds since last midnight.

Protected Attributes

 Socket used by the connection.

Address m_remote
 Remote address that is connected here.

 Owner line.

Transmission * m_trans
Reception * m_recpt
long int m_nextSchedule
 Absolute daytime in milliseconds when transmission is scheduled.

 The channel is the same as m_socket.

Detailed Description

Encapsulates an high level abstract connection between this machine and a remote address.

Connections are objects linking together Sockets, Transmission and Receptions; they are organized in set called Lines, which abstracts the total set of connections transmitting toward a logical client (and eventually receiving from it).

A Connection must reference a Socket object that is the object on which data transfers take places; also, it holds an Address that records the remote addrress of the other end of the logical client. Different connections, even when referencing the same socket, may have different addres because i.e. talking with different remote ports of the same client; also, a Line may group connections insisting on different sockets, or even living on different Channels, because a logical remote client may be reached through different IP addresses (i.e. because having different interfaces).

Connections have necessarily one and only one transmission they are related to. When the connection is destroyed, so does the transmission, and the transmission may not be destroyed nor changed externally.

See also:
Cabal::Transmission for a detailed description of what a transmission is supposed to do.
Connection may also reference one reception, which must be the recetption that superintends packet recival on the socket that is served by this Connection.

The Reception is never used internally, and it's just stored as a convenience field for the application that may be willing to have an handy position where to look for the socket's reception. Also, this helps to implement TCP based Connection, where a socket is effectively served by just one transmission and one reception.

Cabal does not enforces any programming style on the final application (except for being callback-pull based), so even under TCP the Reception listening a socket may or may not be put in a Connection, and it may or may not use internal Cabal structures to interact with the relative transmission object.

Definition at line 68 of file cabal_conn.h.

Constructor & Destructor Documentation

Cabal::Connection::Connection Socket s,
Transmission *  trans,
Reception *  recpt = 0

Creates a Connection.

Connections may be created only on channel bound sockets. Failing to do this will cause an assertion fault.

Definition at line 28 of file ltlib/cabal_conn.cpp.

References Cabal::Socket::incref(), m_channel, m_line, m_nextSchedule, m_socket, and Cabal::Socket::managed().

Member Function Documentation

void Cabal::Connection::account const int  iBytes  )  [inline]

Accounts transmission of bytes on this connection.

This tells the line this connection is connected at that some bytes has been received, and so the bandwidth available for the Line is reduced.

Definition at line 114 of file cabal_conn.h.

References m_channel, m_line, and Cabal::Waiter::usedBandwidth().

void Cabal::Connection::line Line l  )  [inline]

Sets working line.

privatize it and make Line a friend class?

Definition at line 133 of file cabal_conn.h.

References m_line.

Address const& Cabal::Connection::remote  )  const [inline]

Retreives the remote address of this connection.

This file is read-only and cannot be modified.

Definition at line 125 of file cabal_conn.h.

References m_remote.

void Cabal::Connection::schedule const long int  milliseconds,
Priority  prio = medium_prio

Scedule after a certain time in milliseconds.

Use schedule( 0 ) to be called immediately (as soon as possible ). Use Schedule( -1 ) to deschedule this connection (things that removes it effectively from the channel until another schedule is requested.

milliseconds number of milliseconds in the future that this connection wish to sleep before being called again.

Definition at line 55 of file ltlib/cabal_conn.cpp.

References Cabal::Socket::channel(), m_channel, m_line, m_nextSchedule, m_socket, Cabal::Socket::managed(), Cabal::Waiter::minimalWait(), and Cabal::Channel::schedule().

Transmission* Cabal::Connection::transmission  )  const [inline]

Retreives the transmission that is held in this connection.

This field cannot be null.

Definition at line 138 of file cabal_conn.h.

Referenced by Cabal::Channel::process().

Member Data Documentation

Channel* Cabal::Connection::m_channel [protected]

The channel is the same as m_socket.

Is used for code optimization and also to record schedulation status: if the connection is currently scheduled on the channel, this attribute is nonzero.

Definition at line 97 of file cabal_conn.h.

Referenced by account(), Connection(), schedule(), and ~Connection().

Line* Cabal::Connection::m_line [protected]

Owner line.

As the application must dispose the line on its behalf, we don't take reference counts on this object.

Definition at line 85 of file cabal_conn.h.

Referenced by account(), Connection(), line(), and schedule().

Socket* Cabal::Connection::m_socket [protected]

Socket used by the connection.

Notice that the the socket is not owned by one particular connection, but may be shared among many connections.

Definition at line 76 of file cabal_conn.h.

Referenced by Connection(), schedule(), socket(), and ~Connection().

The documentation for this class was generated from the following files:
Generated on Sat Apr 10 17:41:49 2004 for Cabal by doxygen 1.3.5