Main Page   Modules   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members   Related Pages  

GNE::ClientConnection Class Reference
[Mid-Level API]

#include <ClientConnection.h>

Inheritance diagram for GNE::ClientConnection:

GNE::Connection GNE::Thread GNE::ListServerConnection List of all members.

Public Types

typedef SmartPtr< ClientConnection > sptr
typedef WeakPtr< ClientConnection > wptr

Public Member Functions

bool open (const Address &dest, const ConnectionParams &p)
 Opens the socket, ready for connect, but does not yet connect.

void connect ()
 Starts connection to the specified target.

Error waitForConnect ()
 Waits indefinitely for the connection attempt started by connect to finish.


Static Public Member Functions

sptr create ()
 Creates a new ClientConnection object, managed by a SmartPtr.


Protected Member Functions

 ClientConnection ()
 Initializes this ClientConnection.


Friends

class SyncConnection
class boost::weak_ptr< Thread >
class boost::shared_ptr< Thread >
class boost::weak_ptr< Connection >
class boost::shared_ptr< Connection >

Detailed Description

A class that can connect to a remote target.


Member Function Documentation

void GNE::ClientConnection::connect  ) 
 

Starts connection to the specified target.

This method does not block, and a thread will be started to handle the connection process. onConnect() or onConnectFailure() will be called depending on the outcome of this process. The exception is that if an error occurs during onConnect or it chooses to reject the connection, onConnectFailure will also be called.

You can call waitForConnect after connect to wait until the connection is finished, when onConnect or onConnectFailure will be called. When the called function exits, the thread will stop and waitForConnect will return.

The version number for the library and your own version number will be checked during this phase. If either protocol versions mismatch, onConnectFailure() will be triggered.

Precondition:
Connection's state is ReadyToConnect

Connection's state is Connecting (but may change immedately after to another state).

the open method succeeded.

See also:
ConnectionListener::onConnect()

ConnectionListener::onConnectFailure()

ClientConnection::sptr GNE::ClientConnection::create  )  [static]
 

Creates a new ClientConnection object, managed by a SmartPtr.

The listener is passed in the open method.

bool GNE::ClientConnection::open const Address dest,
const ConnectionParams p
 

Opens the socket, ready for connect, but does not yet connect.

All of the relvant parameters for establishing the connection are passed into this function. If there is an error, the function returns true.

Precondition:
Connection's state is NeedsInitialization
Postcondition:
Connection's state is ReadyToConnect
Parameters:
dest the destination address.

Error GNE::ClientConnection::waitForConnect  ) 
 

Waits indefinitely for the connection attempt started by connect to finish.

When the attempt finishes, the result of the connection attempt is returned. If the connection was successful, an error code of Error::NoError is returned.

This is the same Error that is passed to onConnectFailure.

Multiple threads may call this method at any time, even after connection completes (and the return will always be the same). If the connection has already completed this method will return instantly.

Precondition:
connect has been called on this object successfully.


The documentation for this class was generated from the following files:
Generated on Fri Aug 22 13:40:06 2003 for GNE by doxygen1.3