ACE_SOCK_CODgram Class Reference

Defines the member functions for the ACE_SOCK connected datagram abstraction. More...

#include <SOCK_CODgram.h>

Inheritance diagram for ACE_SOCK_CODgram:

Inheritance graph
[legend]
Collaboration diagram for ACE_SOCK_CODgram:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_INET_Addr PEER_ADDR

Public Member Functions

 ACE_SOCK_CODgram (void)
 Default constructor.

 ACE_SOCK_CODgram (const ACE_Addr &remote_sap, const ACE_Addr &local_sap=ACE_Addr::sap_any, int protocol_family=ACE_PROTOCOL_FAMILY_INET, int protocol=0, int reuse_addr=0)
 ~ACE_SOCK_CODgram (void)
 Default dtor.

int open (const ACE_Addr &remote_sap, const ACE_Addr &local_sap=ACE_Addr::sap_any, int protocol_family=ACE_PROTOCOL_FAMILY_INET, int protocol=0, int reuse_addr=0)
 Initiate a connected dgram.

void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Detailed Description

Defines the member functions for the ACE_SOCK connected datagram abstraction.

Definition at line 36 of file SOCK_CODgram.h.


Member Typedef Documentation

typedef ACE_INET_Addr ACE_SOCK_CODgram::PEER_ADDR
 

Definition at line 62 of file SOCK_CODgram.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_SOCK_CODgram::ACE_SOCK_CODgram void   ) 
 

Default constructor.

Definition at line 8 of file SOCK_CODgram.inl.

References ACE_TRACE.

00009 {
00010   ACE_TRACE ("ACE_SOCK_CODgram::ACE_SOCK_CODgram");
00011 }

ACE_SOCK_CODgram::ACE_SOCK_CODgram const ACE_Addr remote_sap,
const ACE_Addr local_sap = ACE_Addr::sap_any,
int  protocol_family = ACE_PROTOCOL_FAMILY_INET,
int  protocol = 0,
int  reuse_addr = 0
 

Definition at line 27 of file SOCK_CODgram.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, and open().

00030 {
00031   ACE_TRACE ("ACE_SOCK_CODgram::ACE_SOCK_CODgram");
00032   if (this->open (remote, local,
00033                   protocol_family, protocol, reuse_addr) == -1)
00034     ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("%p\n"), ACE_LIB_TEXT ("ACE_SOCK_CODgram")));
00035 }

ACE_INLINE ACE_SOCK_CODgram::~ACE_SOCK_CODgram void   ) 
 

Default dtor.

Definition at line 14 of file SOCK_CODgram.inl.

References ACE_TRACE.

00015 {
00016   ACE_TRACE ("ACE_SOCK_CODgram::~ACE_SOCK_CODgram");
00017 }


Member Function Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_SOCK_CODgram::dump void   )  const
 

Dump the state of an object.

Reimplemented from ACE_SOCK_IO.

Reimplemented in ACE_LSOCK_CODgram.

Definition at line 18 of file SOCK_CODgram.cpp.

References ACE_TRACE.

Referenced by ACE_LSOCK_CODgram::dump().

00019 {
00020 #if defined (ACE_HAS_DUMP)
00021   ACE_TRACE ("ACE_SOCK_CODgram::dump");
00022 #endif /* ACE_HAS_DUMP */
00023 }

int ACE_SOCK_CODgram::open const ACE_Addr remote_sap,
const ACE_Addr local_sap = ACE_Addr::sap_any,
int  protocol_family = ACE_PROTOCOL_FAMILY_INET,
int  protocol = 0,
int  reuse_addr = 0
 

Initiate a connected dgram.

Definition at line 59 of file SOCK_CODgram.cpp.

References ACE_TRACE, ACE_OS::bind(), ACE::bind_port(), ACE_SOCK::close(), ACE_OS::connect(), ACE_Addr::get_addr(), ACE_Addr::get_size(), ACE_SOCK::open(), and ACE_IPC_SAP::set_handle().

Referenced by ACE_SOCK_CODgram(), and ACE_LSOCK_CODgram::open().

00062 {
00063   ACE_TRACE ("ACE_SOCK_CODgram::open");
00064   if (ACE_SOCK::open (SOCK_DGRAM, protocol_family,
00065                       protocol, reuse_addr) == -1)
00066     return -1;
00067   else
00068     {
00069       int error = 0;
00070 
00071       if (local == ACE_Addr::sap_any && remote == ACE_Addr::sap_any)
00072         {
00073           // Assign an arbitrary port number from the transient range!!
00074 
00075           if (protocol_family == PF_INET
00076               && ACE::bind_port (this->get_handle ()) == -1)
00077             error = 1;
00078         }
00079       // We are binding just the local address.
00080       else if (local != ACE_Addr::sap_any && remote == ACE_Addr::sap_any)
00081         {
00082           if (ACE_OS::bind (this->get_handle (), (sockaddr *) local.get_addr (),
00083                       local.get_size ()) == -1)
00084             error = 1;
00085         }
00086       // We are connecting to the remote address.
00087       else if (local == ACE_Addr::sap_any && remote != ACE_Addr::sap_any)
00088         {
00089           if (ACE_OS::connect (this->get_handle (), (sockaddr *) remote.get_addr (),
00090                          remote.get_size ()) == -1)
00091             error = 1;
00092         }
00093       // We are binding to the local address and connecting to the
00094       // remote addresses.
00095       else
00096         {
00097           if (ACE_OS::bind (this->get_handle (), (sockaddr *) local.get_addr (),
00098                       local.get_size ()) == -1
00099               || ACE_OS::connect (this->get_handle (), (sockaddr *) remote.get_addr (),
00100                             remote.get_size ()) == -1)
00101             error = 1;
00102         }
00103       if (error)
00104         {
00105           this->close ();
00106           this->set_handle (ACE_INVALID_HANDLE);
00107         }
00108       return error ? -1 : 0;
00109     }
00110 }


Member Data Documentation

ACE_SOCK_CODgram::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_SOCK_IO.

Reimplemented in ACE_LSOCK_CODgram.

Definition at line 68 of file SOCK_CODgram.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:29:47 2006 for ACE by doxygen 1.3.6