Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 Methods

 ACE_SOCK_CODgram (void)
 Default constructor. More...

 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. More...

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. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Detailed Description

Defines the member functions for the ACE_SOCK connected datagram abstraction.

Definition at line 33 of file SOCK_CODgram.h.


Member Typedef Documentation

typedef ACE_INET_Addr ACE_SOCK_CODgram::PEER_ADDR
 

Definition at line 59 of file SOCK_CODgram.h.


Constructor & Destructor Documentation

ASYS_INLINE ACE_SOCK_CODgram::ACE_SOCK_CODgram void   
 

Default constructor.

Definition at line 7 of file SOCK_CODgram.i.

References ACE_TRACE.

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

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 24 of file SOCK_CODgram.cpp.

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

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

ASYS_INLINE ACE_SOCK_CODgram::~ACE_SOCK_CODgram void   
 

Default dtor.

Definition at line 13 of file SOCK_CODgram.i.

References ACE_TRACE.

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


Member Function Documentation

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 17 of file SOCK_CODgram.cpp.

References ACE_TRACE.

Referenced by ACE_LSOCK_CODgram::dump.

00018 {
00019   ACE_TRACE ("ACE_SOCK_CODgram::dump");
00020 }

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 56 of file SOCK_CODgram.cpp.

References ACE_TRACE, ACE_OS::bind, ACE_Sock_Connect::bind_port, ACE_SOCK::close, ACE_OS::connect, ACE_Addr::get_addr, ACE_Addr::get_size, ACE_SOCK::open, ACE_Addr::sap_any, and ACE_IPC_SAP::set_handle.

Referenced by ACE_SOCK_CODgram, and ACE_LSOCK_CODgram::open.

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


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 65 of file SOCK_CODgram.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:56:18 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002