Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes

ACE::HTTP::Session_T< ACE_SYNCH_DECL > Class Template Reference

#include <HTTP_Session.h>

Inheritance diagram for ACE::HTTP::Session_T< ACE_SYNCH_DECL >:
Inheritance graph
[legend]
Collaboration diagram for ACE::HTTP::Session_T< ACE_SYNCH_DECL >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef
ACE::IOS::StreamHandler
< ACE_SOCK_STREAM,
ACE_SYNCH_USE > 
connection_type

Public Member Functions

 Session_T (bool keep_alive=false)
 Session_T (const ACE_Time_Value &timeout, bool keep_alive=false, const ACE_Time_Value *alive_timeout=0)
virtual ~Session_T ()
virtual bool is_connected () const
bool attach_connection (connection_type *connection)

Protected Member Functions

void close_connection ()
virtual bool connect_i (const ACE_Synch_Options &sync_opt)
virtual void close_i ()
virtual std::iostream & sock_stream ()

Private Types

typedef
ACE::IOS::Sock_IOStreamBase
< ACE_SYNCH_USE > 
sock_stream_type

Private Attributes

connection_typeconnection_
sock_stream_typesock_stream_

Detailed Description

template<ACE_SYNCH_DECL>
class ACE::HTTP::Session_T< ACE_SYNCH_DECL >

Definition at line 32 of file HTTP_Session.h.


Member Typedef Documentation

template<ACE_SYNCH_DECL >
typedef ACE::IOS::StreamHandler<ACE_SOCK_STREAM, ACE_SYNCH_USE> ACE::HTTP::Session_T< ACE_SYNCH_DECL >::connection_type

Definition at line 35 of file HTTP_Session.h.

template<ACE_SYNCH_DECL >
typedef ACE::IOS::Sock_IOStreamBase<ACE_SYNCH_USE> ACE::HTTP::Session_T< ACE_SYNCH_DECL >::sock_stream_type [private]

Definition at line 60 of file HTTP_Session.h.


Constructor & Destructor Documentation

template<ACE_SYNCH_DECL >
ACE::HTTP::Session_T< ACE_SYNCH_DECL >::Session_T ( bool  keep_alive = false  ) 

Definition at line 25 of file HTTP_Session.cpp.

      : SessionBase (URL::HTTP_PORT, keep_alive),
        connection_ (0),
        sock_stream_ (0)
      {
        INET_TRACE ("ACE_HTTP_Session - ctor");
      }

template<ACE_SYNCH_DECL >
ACE::HTTP::Session_T< ACE_SYNCH_DECL >::Session_T ( const ACE_Time_Value timeout,
bool  keep_alive = false,
const ACE_Time_Value alive_timeout = 0 
)

Definition at line 34 of file HTTP_Session.cpp.

      : SessionBase (URL::HTTP_PORT, timeout, keep_alive, alive_timeout),
        connection_ (0),
        sock_stream_ (0)
      {
        INET_TRACE ("ACE_HTTP_Session - ctor");
      }

template<ACE_SYNCH_DECL >
ACE::HTTP::Session_T< ACE_SYNCH_DECL >::~Session_T (  )  [virtual]

Definition at line 45 of file HTTP_Session.cpp.

      {
        INET_TRACE ("ACE_HTTP_Session - dtor");
        this->close_streams ();
        this->close_connection ();
      }


Member Function Documentation

template<ACE_SYNCH_DECL >
bool ACE::HTTP::Session_T< ACE_SYNCH_DECL >::attach_connection ( connection_type connection  ) 

Definition at line 111 of file HTTP_Session.cpp.

      {
        INET_TRACE ("ACE_HTTP_Session::attach_connection");

        if (!connection->is_connected ())
          return false;

        this->close ();

        ACE_INET_Addr remote;
        connection->peer ().get_remote_addr (remote);
        this->host_ = remote.get_host_name ();
        this->port_ = remote.get_port_number ();

        this->connection_ = connection;
        this->connection_->add_reference ();

        ACE_NEW_NORETURN (this->sock_stream_,
                          sock_stream_type (this->connection_));

        if (this->sock_stream_)
          {
            this->keep_alive_ = true;
            this->keep_alive_timeout_ = ACE_Time_Value::zero;
            this->cannot_reconnect_ = true;
            return true;
          }
        else
          {
            this->close ();
            return false;
          }
      }

template<ACE_SYNCH_DECL >
void ACE::HTTP::Session_T< ACE_SYNCH_DECL >::close_connection (  )  [protected]

Definition at line 146 of file HTTP_Session.cpp.

      {
        if (this->sock_stream_)
          {
            delete this->sock_stream_;
            this->sock_stream_ = 0;
          }

        if (this->connection_)
          {
            // this should be the last referece and removing it
            // causes the connection to be destroyed
            this->connection_->remove_reference ();
            this->connection_ = 0;
          }
      }

template<ACE_SYNCH_DECL >
void ACE::HTTP::Session_T< ACE_SYNCH_DECL >::close_i ( void   )  [protected, virtual]

Implements ACE::HTTP::SessionBase.

Definition at line 164 of file HTTP_Session.cpp.

      {
        INET_TRACE ("ACE_HTTP_Session::close_i");

        this->close_connection ();
      }

template<ACE_SYNCH_DECL >
bool ACE::HTTP::Session_T< ACE_SYNCH_DECL >::connect_i ( const ACE_Synch_Options sync_opt  )  [protected, virtual]

Implements ACE::HTTP::SessionBase.

Definition at line 59 of file HTTP_Session.cpp.

      {
        INET_TRACE ("ACE_HTTP_Session::connect_i");

        typedef ACE_Connector<connection_type, ACE_SOCK_CONNECTOR> connector_type;

        connector_type connector;

        connection_type* new_connection = 0;
        ACE_NEW_RETURN (new_connection,
                        connection_type(sync_opt),
                        false);
        if (connector.connect (new_connection,
                               ACE_INET_Addr (this->port_,
                                              this->host_.c_str ()),
                               ACE_Synch_Options (0,this->http_timeout_)) == -1)
          {
            INET_ERROR (1, (LM_ERROR, DLINFO
                            ACE_TEXT ("(%d) ACE_HTTP_Session::connect_i - ")
                            ACE_TEXT ("failed to connect; host=%C, port=%d\n"),
                            ACE_OS::last_error (), this->host_.c_str (), this->port_));
            // as the connection was dynamically allocated
            // the connector causes it to be destroyed after
            // the connection failure
            return false;
          }

        this->connection_ = new_connection;
        this->connection_->reference_counting_policy ().value (
            ACE_Event_Handler::Reference_Counting_Policy::ENABLED);

        ACE_NEW_NORETURN (this->sock_stream_,
                          sock_stream_type (this->connection_));
        if (this->sock_stream_)
          {
            this->cannot_reconnect_ = false;
            this->reactive_ = sync_opt[ACE_Synch_Options::USE_REACTOR];

            // reset reconnect timer
            this->reconnect_timer_ = this->keep_alive_timeout_;
            this->reconnect_countdown_.start ();

            return true;
          }
        else
          {
            this->close ();
            return false;
          }
      }

template<ACE_SYNCH_DECL >
bool ACE::HTTP::Session_T< ACE_SYNCH_DECL >::is_connected (  )  const [virtual]

Implements ACE::HTTP::SessionBase.

Definition at line 53 of file HTTP_Session.cpp.

      {
        return this->connection_ && this->connection_->is_connected ();
      }

template<ACE_SYNCH_DECL >
std::iostream & ACE::HTTP::Session_T< ACE_SYNCH_DECL >::sock_stream (  )  [protected, virtual]

Implements ACE::HTTP::SessionBase.

Definition at line 172 of file HTTP_Session.cpp.

      {
        return *this->sock_stream_;
      }


Member Data Documentation

template<ACE_SYNCH_DECL >
connection_type* ACE::HTTP::Session_T< ACE_SYNCH_DECL >::connection_ [private]

Definition at line 62 of file HTTP_Session.h.

template<ACE_SYNCH_DECL >
sock_stream_type* ACE::HTTP::Session_T< ACE_SYNCH_DECL >::sock_stream_ [private]

Definition at line 63 of file HTTP_Session.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines