Public Member Functions | Private Attributes

TAO_DIOP_Transport Class Reference

Specialization of the base TAO_Transport class to handle the DIOP protocol. More...

#include <DIOP_Transport.h>

Inheritance diagram for TAO_DIOP_Transport:
Inheritance graph
[legend]
Collaboration diagram for TAO_DIOP_Transport:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_DIOP_Transport (TAO_DIOP_Connection_Handler *handler, TAO_ORB_Core *orb_core)
 Constructor.
 ~TAO_DIOP_Transport (void)
 Default destructor.
virtual int handle_input (TAO_Resume_Handle &rh, ACE_Time_Value *max_wait_time=0)
 Look for the documentation in Transport.h.
virtual int send_request (TAO_Stub *stub, TAO_ORB_Core *orb_core, TAO_OutputCDR &stream, TAO_Message_Semantics message_semantics, ACE_Time_Value *max_wait_time)
virtual int send_message (TAO_OutputCDR &stream, TAO_Stub *stub=0, TAO_Message_Semantics message_semantics=TAO_TWOWAY_REQUEST, ACE_Time_Value *max_time_wait=0)

Protected Member Functions

Overridden Template Methods

These are implementations of template methods declared by TAO_Transport.

virtual ACE_Event_Handlerevent_handler_i (void)
 Write the complete Message_Block chain to the connection.
virtual TAO_Connection_Handlerconnection_handler_i (void)
 Write the complete Message_Block chain to the connection.
virtual ssize_t send (iovec *iov, int iovcnt, size_t &bytes_transferred, const ACE_Time_Value *max_wait_time)
 Write the complete Message_Block chain to the connection.
virtual ssize_t recv (char *buf, size_t len, const ACE_Time_Value *s=0)
 Read len bytes from into buf.
virtual int register_handler (void)
 Write the complete Message_Block chain to the connection.

Private Attributes

TAO_DIOP_Connection_Handlerconnection_handler_

Detailed Description

Specialization of the base TAO_Transport class to handle the DIOP protocol.

Definition at line 53 of file DIOP_Transport.h.


Constructor & Destructor Documentation

TAO_DIOP_Transport::TAO_DIOP_Transport ( TAO_DIOP_Connection_Handler handler,
TAO_ORB_Core orb_core 
)

Constructor.

Definition at line 26 of file DIOP_Transport.cpp.

  : TAO_Transport (TAO_TAG_DIOP_PROFILE,
                   orb_core,
                   ACE_MAX_DGRAM_SIZE)
  , connection_handler_ (handler)
{
}

TAO_DIOP_Transport::~TAO_DIOP_Transport ( void   ) 

Default destructor.

Definition at line 35 of file DIOP_Transport.cpp.

{
}


Member Function Documentation

TAO_Connection_Handler * TAO_DIOP_Transport::connection_handler_i ( void   )  [protected, virtual]

Write the complete Message_Block chain to the connection.

Implements TAO_Transport.

Definition at line 46 of file DIOP_Transport.cpp.

{
  return this->connection_handler_;
}

ACE_Event_Handler * TAO_DIOP_Transport::event_handler_i ( void   )  [protected, virtual]

Write the complete Message_Block chain to the connection.

Implements TAO_Transport.

Definition at line 40 of file DIOP_Transport.cpp.

{
  return this->connection_handler_;
}

int TAO_DIOP_Transport::handle_input ( TAO_Resume_Handle rh,
ACE_Time_Value max_wait_time = 0 
) [virtual]

Look for the documentation in Transport.h.

Reimplemented from TAO_Transport.

Definition at line 124 of file DIOP_Transport.cpp.

{
  // If there are no messages then we can go ahead to read from the
  // handle for further reading..

  // The buffer on the stack which will be used to hold the input
  // messages
  char buf [ACE_MAX_DGRAM_SIZE + ACE_CDR::MAX_ALIGNMENT];

#if defined (ACE_INITIALIZE_MEMORY_BEFORE_USE)
  (void) ACE_OS::memset (buf,
                         '\0',
                         sizeof buf);
#endif /* ACE_INITIALIZE_MEMORY_BEFORE_USE */

  // Create a data block
  ACE_Data_Block db (sizeof (buf),
                     ACE_Message_Block::MB_DATA,
                     buf,
                     this->orb_core_->input_cdr_buffer_allocator (),
                     this->orb_core_->locking_strategy (),
                     ACE_Message_Block::DONT_DELETE,
                     this->orb_core_->input_cdr_dblock_allocator ());

  // Create a message block
  ACE_Message_Block message_block (&db,
                                   ACE_Message_Block::DONT_DELETE,
                                   this->orb_core_->input_cdr_msgblock_allocator ());


  // Align the message block
  ACE_CDR::mb_align (&message_block);


  // Read the message into the  message block that we have created on
  // the stack.
  ssize_t n = this->recv (message_block.rd_ptr (),
                          message_block.space (),
                          max_wait_time);

  // If there is an error return to the reactor..
  if (n <= 0)
    {
      if (n == -1)
        {
          this->tms_->connection_closed ();
        }

      return n;
    }

  // Set the write pointer in the stack buffer
  message_block.wr_ptr (n);

  // Make a node of the message block..
  TAO_Queued_Data qd (&message_block);
  size_t mesg_length = 0;

  // Parse the incoming message for validity. The check needs to be
  // performed by the messaging objects.
  if (this->messaging_object ()->parse_next_message (qd, mesg_length) == -1)
    return -1;

  if (qd.missing_data () == TAO_MISSING_DATA_UNDEFINED)
    {
      // parse/marshal error
      return -1;
    }

  if (message_block.length () > mesg_length)
    {
      // we read too much data
      return -1;
    }

  // NOTE: We are not performing any queueing nor any checking for
  // missing data. We are assuming that ALL the data would be got in a
  // single read.

  // Process the message
  return this->process_parsed_messages (&qd, rh);
}

ssize_t TAO_DIOP_Transport::recv ( char *  buf,
size_t  len,
const ACE_Time_Value s = 0 
) [protected, virtual]

Read len bytes from into buf.

Implements TAO_Transport.

Definition at line 74 of file DIOP_Transport.cpp.

{
  ACE_INET_Addr from_addr;

  ssize_t const n = this->connection_handler_->peer ().recv (buf, len, from_addr);

  if (TAO_debug_level > 0)
    {
      ACE_DEBUG ((LM_DEBUG,
                  "TAO (%P|%t) - DIOP_Transport::recv, received %d bytes from %C:%d %d\n",
                  n,
                  from_addr.get_host_name (),
                  from_addr.get_port_number (),
                  ACE_ERRNO_GET));
    }

  // Most of the errors handling is common for
  // Now the message has been read
  if (n == -1 && TAO_debug_level > 4)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("TAO (%P|%t) - DIOP_Transport::recv, %p\n"),
                  ACE_TEXT ("TAO - read message failure ")
                  ACE_TEXT ("recv ()\n")));
    }

  // Error handling
  if (n == -1)
    {
      if (errno == EWOULDBLOCK)
        return 0;

      return -1;
    }
  // @@ What are the other error handling here??
  else if (n == 0)
    {
      return -1;
    }

  // Remember the from addr to eventually use it as remote
  // addr for the reply.
  this->connection_handler_->addr (from_addr);

  return n;
}

int TAO_DIOP_Transport::register_handler ( void   )  [protected, virtual]

Write the complete Message_Block chain to the connection.

Reimplemented from TAO_Transport.

Definition at line 210 of file DIOP_Transport.cpp.

{
  // @@ Michael:
  //
  // We do never register register the handler with the reactor
  // as we never need to be informed about any incoming data,
  // assuming we only use one-ways.
  // If we would register and ICMP Messages would arrive, e.g
  // due to a not reachable server, we would get informed - as this
  // disturbs the general DIOP assumptions of not being
  // interested in any network failures, we ignore ICMP messages.
  return 0;
}

ssize_t TAO_DIOP_Transport::send ( iovec *  iov,
int  iovcnt,
size_t &  bytes_transferred,
const ACE_Time_Value max_wait_time 
) [protected, virtual]

Write the complete Message_Block chain to the connection.

Implements TAO_Transport.

Definition at line 52 of file DIOP_Transport.cpp.

{
  const ACE_INET_Addr &addr = this->connection_handler_->addr ();

  ssize_t bytes_to_send = 0;
  for (int i = 0; i < iovcnt; i++)
     bytes_to_send += iov[i].iov_len;

  this->connection_handler_->peer ().send (iov, iovcnt, addr);

  // @@ Michael:
  // Always return a positive number of bytes sent, as we do
  // not handle sending errors in DIOP.

  bytes_transferred = bytes_to_send;

  return 1;
}

int TAO_DIOP_Transport::send_message ( TAO_OutputCDR stream,
TAO_Stub stub = 0,
TAO_Message_Semantics  message_semantics = TAO_TWOWAY_REQUEST,
ACE_Time_Value max_time_wait = 0 
) [virtual]

This method formats the stream and then sends the message on the transport. Once the ORB is prepared to receive a reply (see send_request() above), and all the arguments have been marshaled the CDR stream must be 'formatted', i.e. the message_size field in the GIOP header can finally be set to the proper value.

Implements TAO_Transport.

Definition at line 248 of file DIOP_Transport.cpp.

{
  // Format the message in the stream first
  if (this->messaging_object ()->format_message (stream, stub) != 0)
    return -1;

  // Strictly speaking, should not need to loop here because the
  // socket never gets set to a nonblocking mode ... some Linux
  // versions seem to need it though.  Leaving it costs little.

  // This guarantees to send all data (bytes) or return an error.
  ssize_t const n = this->send_message_shared (stub,
                                               message_semantics,
                                               stream.begin (),
                                               max_wait_time);

  if (n == -1)
    {
      if (TAO_debug_level)
        ACE_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("TAO (%P|%t) - DIOP_Transport::send_message, ")
                    ACE_TEXT ("closing transport %d after fault %p\n"),
                    this->id (),
                    ACE_TEXT ("send_message ()\n")));

      return -1;
    }

  return 1;
}

int TAO_DIOP_Transport::send_request ( TAO_Stub stub,
TAO_ORB_Core orb_core,
TAO_OutputCDR stream,
TAO_Message_Semantics  message_semantics,
ACE_Time_Value max_wait_time 
) [virtual]
Todo:
These methods IMHO should have more meaningful names. The names seem to indicate nothing.

Implements TAO_Transport.

Definition at line 226 of file DIOP_Transport.cpp.

{
  if (this->ws_->sending_request (orb_core, message_semantics) == -1)
    return -1;

  if (this->send_message (stream,
                          stub,
                          message_semantics,
                          max_wait_time) == -1)

    return -1;

  this->first_request_sent ();

  return 0;
}


Member Data Documentation

The connection service handler used for accessing lower layer communication protocols.

Definition at line 108 of file DIOP_Transport.h.


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