summaryrefslogtreecommitdiff
path: root/ace/SOCK_CODgram.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/SOCK_CODgram.cpp')
-rw-r--r--ace/SOCK_CODgram.cpp79
1 files changed, 38 insertions, 41 deletions
diff --git a/ace/SOCK_CODgram.cpp b/ace/SOCK_CODgram.cpp
index 8bacd9d1220..766819b1eb1 100644
--- a/ace/SOCK_CODgram.cpp
+++ b/ace/SOCK_CODgram.cpp
@@ -1,3 +1,4 @@
+// SOCK_CODgram.cpp
// $Id$
#include "ace/SOCK_CODgram.h"
@@ -10,8 +11,6 @@
ACE_RCSID(ace, SOCK_CODgram, "$Id$")
-ACE_BEGIN_VERSIONED_NAMESPACE_DECL
-
ACE_ALLOC_HOOK_DEFINE(ACE_SOCK_CODgram)
void
@@ -25,12 +24,12 @@ ACE_SOCK_CODgram::dump (void) const
// Here's the general-purpose constructor.
ACE_SOCK_CODgram::ACE_SOCK_CODgram (const ACE_Addr &remote, const ACE_Addr &local,
- int protocol_family, int protocol,
- int reuse_addr)
+ int protocol_family, int protocol,
+ int reuse_addr)
{
ACE_TRACE ("ACE_SOCK_CODgram::ACE_SOCK_CODgram");
if (this->open (remote, local,
- protocol_family, protocol, reuse_addr) == -1)
+ protocol_family, protocol, reuse_addr) == -1)
ACE_ERROR ((LM_ERROR, ACE_LIB_TEXT ("%p\n"), ACE_LIB_TEXT ("ACE_SOCK_CODgram")));
}
@@ -40,73 +39,71 @@ ACE_SOCK_CODgram::ACE_SOCK_CODgram (const ACE_Addr &remote, const ACE_Addr &loca
1. remote == ACE_Addr::sap_any && local == ACE_Addr::sap_any
if protocol_family == PF_INET then
- bind the local address to a randomly generated port number...
+ bind the local address to a randomly generated port number...
2. remote == ACE_Addr::sap_any && local != ACE_Addr::sap_any
we are just binding the local address
- (used primarily by servers)
+ (used primarily by servers)
3. remote != ACE_Addr::sap_any && local == ACE_Addr::sap_any
we are connecting to the remote address
- (used primarily by clients)
+ (used primarily by clients)
4. remote != ACE_Addr::sap_any && local != ACE_Addr::sap_any
we are binding to the local address
- and connecting to the remote address
+ and connecting to the remote address
*/
int
ACE_SOCK_CODgram::open (const ACE_Addr &remote, const ACE_Addr &local,
- int protocol_family, int protocol,
- int reuse_addr)
+ int protocol_family, int protocol,
+ int reuse_addr)
{
ACE_TRACE ("ACE_SOCK_CODgram::open");
if (ACE_SOCK::open (SOCK_DGRAM, protocol_family,
- protocol, reuse_addr) == -1)
+ protocol, reuse_addr) == -1)
return -1;
else
{
int error = 0;
if (local == ACE_Addr::sap_any && remote == ACE_Addr::sap_any)
- {
- // Assign an arbitrary port number from the transient range!!
+ {
+ // Assign an arbitrary port number from the transient range!!
- if (protocol_family == PF_INET
- && ACE::bind_port (this->get_handle ()) == -1)
- error = 1;
- }
+ if (protocol_family == PF_INET
+ && ACE::bind_port (this->get_handle ()) == -1)
+ error = 1;
+ }
// We are binding just the local address.
else if (local != ACE_Addr::sap_any && remote == ACE_Addr::sap_any)
- {
- if (ACE_OS::bind (this->get_handle (), (sockaddr *) local.get_addr (),
- local.get_size ()) == -1)
- error = 1;
- }
+ {
+ if (ACE_OS::bind (this->get_handle (), (sockaddr *) local.get_addr (),
+ local.get_size ()) == -1)
+ error = 1;
+ }
// We are connecting to the remote address.
else if (local == ACE_Addr::sap_any && remote != ACE_Addr::sap_any)
- {
- if (ACE_OS::connect (this->get_handle (), (sockaddr *) remote.get_addr (),
- remote.get_size ()) == -1)
- error = 1;
- }
+ {
+ if (ACE_OS::connect (this->get_handle (), (sockaddr *) remote.get_addr (),
+ remote.get_size ()) == -1)
+ error = 1;
+ }
// We are binding to the local address and connecting to the
// remote addresses.
else
- {
- if (ACE_OS::bind (this->get_handle (), (sockaddr *) local.get_addr (),
- local.get_size ()) == -1
- || ACE_OS::connect (this->get_handle (), (sockaddr *) remote.get_addr (),
- remote.get_size ()) == -1)
- error = 1;
- }
+ {
+ if (ACE_OS::bind (this->get_handle (), (sockaddr *) local.get_addr (),
+ local.get_size ()) == -1
+ || ACE_OS::connect (this->get_handle (), (sockaddr *) remote.get_addr (),
+ remote.get_size ()) == -1)
+ error = 1;
+ }
if (error)
- {
- this->close ();
- this->set_handle (ACE_INVALID_HANDLE);
- }
+ {
+ this->close ();
+ this->set_handle (ACE_INVALID_HANDLE);
+ }
return error ? -1 : 0;
}
}
-
-ACE_END_VERSIONED_NAMESPACE_DECL