ulxr::Connection Class Reference
[A connection for an XML-RPC call]

Base class for connection between XML RPC client and server. More...

#include <ulxr_connection.h>

Inheritance diagram for ulxr::Connection:

Inheritance graph
[legend]
Collaboration diagram for ulxr::Connection:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Connection ()
 Constructs a connection.
virtual ~Connection ()
 Destroys the connection.
virtual void close ()
 Closes the connection.
virtual void shutdown (int mode)=0
 Shuts down the socket.
virtual Connectiondetach ()=0
 Detaches the connection by creating a duplicate of the connection and closing the original connection afterwards.
virtual void write (char const *buff, long len)
 Writes data to the connection.
virtual ssize_t read (char *buff, long len)
 Reads data from the connection.
virtual void open ()=0
 Opens the connection in rpc client mode.
virtual bool accept (int timeout=0)=0
 Opens the connection in rpc server mode, thus waiting for connections from clients.
virtual bool isOpen () const
 Tests if the connection is open.
void setTimeout (unsigned to_sec)
 Sets the maximum time it is waited to complete an action like open or read.
void setConnectionTimeout (unsigned def_to_sec=0, unsigned alive_to_sec=0)
 Stores the maximum times for connections with a single transmission a or an alive connection between multiple transmissions.
unsigned getTimeout () const
 Gets the maximum time it is waited to complete an action like open or read.
unsigned getDefaultTimeout () const
 Gets the default timeout for single transmission connections.
unsigned getPersistentTimeout () const
 Gets the alive timeout for alive connections for multiple transactions.
virtual int getLastError ()
 Portable function to return the current error number.
virtual CppString getErrorString (int err_number)
 Portable function to return the error description for a given error number.
virtual CppString getInterfaceName ()=0
 Tests if the current transmission expects a return value.
virtual void cut ()
 Cuts the connection.
int getHandle () const
 Returns the file handle of the connection.
virtual int getServerHandle ()=0
 Returns the server connection handle.
void doConnect ()
 Connect to a proxy or firewall after creating the socket.
void setConnector (ConnectorWrapperBase *connector)
 Sets the callback to the proxy connector.

Protected Member Functions

void setHandle (int handle)
 Sets the file handle of the connection.
bool isConnecting () const
 Checks if the http CONNECT is in progress.
void setIsConnecting (bool connecting)
 Reflects the state when the http CONNECT is in progress.
virtual ssize_t low_level_write (char const *buff, long len)
 Actually writes data to the connection.
virtual ssize_t low_level_read (char *buff, long len)
 Reads data from the connection.
virtual bool hasPendingInput () const
 Checks if there is input dta which can innediately be read.

Private Member Functions

void init ()
 Initializes internal variables.

Private Attributes

bool isconnecting
ConnectorWrapperBaseconnector
int fd_handle
unsigned current_to
unsigned default_to
unsigned persist_to

Detailed Description

Base class for connection between XML RPC client and server.

Definition at line 92 of file ulxr_connection.h.


Constructor & Destructor Documentation

ulxr::Connection::Connection (  ) 

Constructs a connection.

The connection is not yet open after construction.

Definition at line 85 of file ulxr_connection.cpp.

References init(), ULXR_PCHAR, and ULXR_TRACE.

ulxr::Connection::~Connection (  )  [virtual]

Destroys the connection.

The connection is closed now at the latest.

Definition at line 92 of file ulxr_connection.cpp.

References close(), connector, ULXR_PCHAR, and ULXR_TRACE.


Member Function Documentation

void ulxr::Connection::close (  )  [virtual]

Closes the connection.

Reimplemented in ulxr::SSLConnection, ulxr::TcpIpConnection, and funtik::SSLConnection.

Definition at line 571 of file ulxr_connection.cpp.

References ulxr::TransportError, ULXR_PCHAR, and ULXR_TRACE.

Referenced by ulxr::TcpIpConnection::close(), and ~Connection().

virtual void ulxr::Connection::shutdown ( int  mode  )  [pure virtual]

Shuts down the socket.

Only meaningful for certain connections based on TcpIpConnection.

Parameters:
mode shutdown mode
  • Unix: SHUT_RD, SHUT_WR or SHUT_RDWR
  • Win32: SD_RECEIVE, SD_SEND or SD_BOTH

Implemented in ulxr::TcpIpConnection.

virtual Connection* ulxr::Connection::detach (  )  [pure virtual]

Detaches the connection by creating a duplicate of the connection and closing the original connection afterwards.

Returns:
the current connection

Implemented in ulxr::TcpIpConnection, and funtik::SSLConnection.

void ulxr::Connection::write ( char const *  buff,
long  len 
) [virtual]

Writes data to the connection.

Parameters:
buff pointer to data
len valid buffer length

Definition at line 129 of file ulxr_connection.cpp.

References ulxr::ApplicationError, ulxr::SystemError, ulxr::TransportError, ULXR_DOUT_WRITE, ULXR_DWRITE_WRITE, ulxr_i18n, ULXR_PCHAR, and ULXR_TRACE.

Referenced by ulxr::Log4JSender::send().

ssize_t ulxr::Connection::read ( char *  buff,
long  len 
) [virtual]

Reads data from the connection.

Parameters:
buff pointer to data buffer
len maimum number of bytes to read into buffer
Returns:
number of actually read bytes

Definition at line 348 of file ulxr_connection.cpp.

References ulxr::ApplicationError, ulxr::HtmlFormHandler::makeNumber(), ulxr::SystemError, ulxr::TransportError, ULXR_DWRITE_READ, ulxr_i18n, ULXR_PCHAR, and ULXR_TRACE.

virtual void ulxr::Connection::open (  )  [pure virtual]

Opens the connection in rpc client mode.

Implemented in ulxr::SSLConnection, ulxr::TcpIpConnection, and funtik::SSLConnection.

virtual bool ulxr::Connection::accept ( int  timeout = 0  )  [pure virtual]

Opens the connection in rpc server mode, thus waiting for connections from clients.

Parameters:
timeout the timeout value [sec] (0 - no timeout)
Returns:
true when connection has been accepted

Implemented in ulxr::SSLConnection, and ulxr::TcpIpConnection.

bool ulxr::Connection::isOpen (  )  const [virtual]

Tests if the connection is open.

Returns:
true if connection is already open.

Definition at line 108 of file ulxr_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

Referenced by ulxr::Log4JSender::close(), ulxr::Protocol::isOpen(), and ulxr::Log4JSender::open().

void ulxr::Connection::setTimeout ( unsigned  to_sec  ) 

Sets the maximum time it is waited to complete an action like open or read.

Parameters:
to_sec time in seconds

Definition at line 691 of file ulxr_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

Referenced by ulxr::Protocol::setPersistent().

void ulxr::Connection::setConnectionTimeout ( unsigned  def_to_sec = 0,
unsigned  alive_to_sec = 0 
)

Stores the maximum times for connections with a single transmission a or an alive connection between multiple transmissions.

This call only serves as a store for the values. Protocols an other clients must retrieve the according values via getDefaultTimeout() and getPersistentTimeout() and actually set with setTimeout().

Values of 0 implicitly select the current timeout value.

Parameters:
def_to_sec default time in seconds. A value of 0 disables the timeout.
alive_to_sec time while a connection shall remain alive between transmissions.

Definition at line 698 of file ulxr_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

unsigned ulxr::Connection::getTimeout (  )  const

Gets the maximum time it is waited to complete an action like open or read.

Returns:
time in seconds

Definition at line 706 of file ulxr_connection.cpp.

Referenced by ulxr::TcpIpConnection::TcpIpConnection().

unsigned ulxr::Connection::getDefaultTimeout (  )  const

Gets the default timeout for single transmission connections.

Returns:
time in seconds

Definition at line 712 of file ulxr_connection.cpp.

Referenced by ulxr::Protocol::setPersistent().

unsigned ulxr::Connection::getPersistentTimeout (  )  const

Gets the alive timeout for alive connections for multiple transactions.

Returns:
time in seconds

Definition at line 721 of file ulxr_connection.cpp.

Referenced by ulxr::Protocol::setPersistent().

int ulxr::Connection::getLastError (  )  [virtual]

Portable function to return the current error number.

Returns:
error number (errno under Unices)

Reimplemented in ulxr::TcpIpConnection.

Definition at line 597 of file ulxr_connection.cpp.

Referenced by ulxr::Requester::startDispatch().

CppString ulxr::Connection::getErrorString ( int  err_number  )  [virtual]

Portable function to return the error description for a given error number.

Parameters:
err_number system dependent error code
Returns:
error string

Definition at line 607 of file ulxr_connection.cpp.

References ulxr::getLastErrorString(), ULXR_GET_STRING, ulxr_i18n, and ULXR_PCHAR.

Referenced by ulxr::TcpIpConnection::TcpIpConnection().

virtual CppString ulxr::Connection::getInterfaceName (  )  [pure virtual]

Tests if the current transmission expects a return value.

Returns:
true: return value for request

Implemented in ulxr::SSLConnection, ulxr::TcpIpConnection, and funtik::SSLConnection.

void ulxr::Connection::cut (  )  [virtual]

Cuts the connection.

Just the variables are reset, the connection itself is not touched.

Reimplemented in ulxr::SSLConnection, and funtik::SSLConnection.

Definition at line 564 of file ulxr_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

Referenced by ulxr::SSLConnection::cut(), and funtik::SSLConnection::cut().

int ulxr::Connection::getHandle (  )  const

Returns the file handle of the connection.

Returns:
the file handle

Definition at line 634 of file ulxr_connection.cpp.

Referenced by ulxr::TcpIpConnection::detach().

virtual int ulxr::Connection::getServerHandle (  )  [pure virtual]

Returns the server connection handle.

Returns:
file handle

Implemented in ulxr::TcpIpConnection.

void ulxr::Connection::doConnect (  ) 

Connect to a proxy or firewall after creating the socket.

Definition at line 658 of file ulxr_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

void ulxr::Connection::setConnector ( ConnectorWrapperBase connector  ) 

Sets the callback to the proxy connector.

Parameters:
connector connector callback

Definition at line 684 of file ulxr_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

void ulxr::Connection::setHandle ( int  handle  )  [protected]

Sets the file handle of the connection.

Parameters:
handle the file handle

Definition at line 640 of file ulxr_connection.cpp.

bool ulxr::Connection::isConnecting (  )  const [protected]

Checks if the http CONNECT is in progress.

Returns:
true: CONNECT is running

Definition at line 646 of file ulxr_connection.cpp.

void ulxr::Connection::setIsConnecting ( bool  connecting  )  [protected]

Reflects the state when the http CONNECT is in progress.

In this case encryption must temporarily be turned off to authenticate with a firewall.

Parameters:
connecting true: CONNECT is running

Definition at line 652 of file ulxr_connection.cpp.

ssize_t ulxr::Connection::low_level_write ( char const *  buff,
long  len 
) [protected, virtual]

Actually writes data to the connection.

Parameters:
buff pointer to data
len valid buffer length
Returns:
result from api write function

Reimplemented in ulxr::SSLConnection, and funtik::SSLConnection.

Definition at line 116 of file ulxr_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

Referenced by ulxr::SSLConnection::low_level_write().

ssize_t ulxr::Connection::low_level_read ( char *  buff,
long  len 
) [protected, virtual]

Reads data from the connection.

Parameters:
buff pointer to data buffer
len maimum number of bytes to read into buffer
Returns:
result from api read function

Reimplemented in ulxr::SSLConnection, and funtik::SSLConnection.

Definition at line 338 of file ulxr_connection.cpp.

Referenced by ulxr::SSLConnection::low_level_read().

bool ulxr::Connection::hasPendingInput (  )  const [protected, virtual]

Checks if there is input dta which can innediately be read.

Returns:
true: data available

Reimplemented in ulxr::SSLConnection, and funtik::SSLConnection.

Definition at line 332 of file ulxr_connection.cpp.

Referenced by ulxr::SSLConnection::hasPendingInput().

void ulxr::Connection::init (  )  [private]

Initializes internal variables.

Reimplemented in ulxr::SSLConnection, and funtik::SSLConnection.

Definition at line 71 of file ulxr_connection.cpp.

References ULXR_PCHAR, and ULXR_TRACE.

Referenced by Connection(), and ulxr::TcpIpConnection::TcpIpConnection().


Member Data Documentation

bool ulxr::Connection::isconnecting [private]

Definition at line 272 of file ulxr_connection.h.

ConnectorWrapperBase* ulxr::Connection::connector [private]

Definition at line 273 of file ulxr_connection.h.

Referenced by ~Connection().

int ulxr::Connection::fd_handle [private]

Definition at line 274 of file ulxr_connection.h.

unsigned ulxr::Connection::current_to [private]

Definition at line 276 of file ulxr_connection.h.

unsigned ulxr::Connection::default_to [private]

Definition at line 277 of file ulxr_connection.h.

unsigned ulxr::Connection::persist_to [private]

Definition at line 278 of file ulxr_connection.h.


The documentation for this class was generated from the following files:
Generated on Sun Aug 19 20:09:02 2007 for ulxmlrpcpp by  doxygen 1.5.1