#include <cabal_conn.h>
Collaboration diagram for Cabal::Connection:
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. | |
Socket * | socket () const |
Retreives the socket used by this connection. | |
Address const & | remote () const |
Retreives the remote address of this connection. | |
Line * | line () 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 * | m_socket |
Socket used by the connection. | |
Address | m_remote |
Remote address that is connected here. | |
Line * | m_line |
Owner line. | |
Transmission * | m_trans |
Reception * | m_recpt |
long int | m_nextSchedule |
Absolute daytime in milliseconds when transmission is scheduled. | |
Channel * | m_channel |
The channel is the same as m_socket. |
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.
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.
|
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(). |
|
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(). |
|
Sets working line. privatize it and make Line a friend class? Definition at line 133 of file cabal_conn.h. References m_line. |
|
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. |
|
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.
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(). |
|
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(). |
|
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(). |
|
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 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(). |