summaryrefslogtreecommitdiff
path: root/ace/SOCK_Acceptor.cpp
diff options
context:
space:
mode:
authornobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-26 18:32:32 +0000
committernobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-07-26 18:32:32 +0000
commitf589fce750a69465231f7267f35d0d2965571dde (patch)
tree40f43ecf50497512d340f015d4d4da867344a086 /ace/SOCK_Acceptor.cpp
parent7aca63cabc7d12d4f0687c39fbe096b38fed9068 (diff)
downloadATCD-ami_phase4_end.tar.gz
This commit was manufactured by cvs2svn to create tagami_phase4_end
'ami_phase4_end'.
Diffstat (limited to 'ace/SOCK_Acceptor.cpp')
-rw-r--r--ace/SOCK_Acceptor.cpp164
1 files changed, 74 insertions, 90 deletions
diff --git a/ace/SOCK_Acceptor.cpp b/ace/SOCK_Acceptor.cpp
index 612dd023028..96726920173 100644
--- a/ace/SOCK_Acceptor.cpp
+++ b/ace/SOCK_Acceptor.cpp
@@ -71,9 +71,8 @@ ACE_SOCK_Acceptor::shared_accept_finish (ACE_SOCK_Stream new_stream,
{
// Save/restore errno.
ACE_Errno_Guard error (errno);
-
- // Only disable ACE_NONBLOCK if we weren't in non-blocking mode
- // originally.
+ // Only disable ACE_NONBLOCK if we weren't in
+ // non-blocking mode originally.
ACE::clr_flags (this->get_handle (),
ACE_NONBLOCK);
ACE::clr_flags (new_handle,
@@ -195,62 +194,29 @@ ACE_SOCK_Acceptor::accept (ACE_SOCK_Stream &new_stream,
reset_new_handle);
}
-void
-ACE_SOCK_Acceptor::dump (void) const
+// General purpose routine for performing server ACE_SOCK creation.
+
+ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap,
+ int reuse_addr,
+ int protocol_family,
+ int backlog,
+ int protocol)
{
- ACE_TRACE ("ACE_SOCK_Acceptor::dump");
+ ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor");
+ if (this->open (local_sap,
+ reuse_addr,
+ protocol_family,
+ backlog,
+ protocol) == -1)
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("%p\n"),
+ ASYS_TEXT ("ACE_SOCK_Acceptor")));
}
-int
-ACE_SOCK_Acceptor::shared_open (const ACE_Addr &local_sap,
- int protocol_family,
- int backlog)
+void
+ACE_SOCK_Acceptor::dump (void) const
{
- ACE_TRACE ("ACE_SOCK_Acceptor::shared_open");
- int error = 0;
-
- if (protocol_family == PF_INET)
- {
- sockaddr_in local_inet_addr;
- ACE_OS::memset (ACE_reinterpret_cast (void *,
- &local_inet_addr),
- 0,
- sizeof local_inet_addr);
-
- if (local_sap == ACE_Addr::sap_any)
- {
- local_inet_addr.sin_port = 0;
- local_inet_addr.sin_addr.s_addr = htonl (INADDR_ANY);
- }
- else
- local_inet_addr = *ACE_reinterpret_cast (sockaddr_in *,
- local_sap.get_addr ());
- if (local_inet_addr.sin_port == 0)
- {
- if (ACE::bind_port (this->get_handle (),
- local_inet_addr.sin_addr.s_addr) == -1)
- error = 1;
- }
- else if (ACE_OS::bind (this->get_handle (),
- ACE_reinterpret_cast (sockaddr *,
- &local_inet_addr),
- sizeof local_inet_addr) == -1)
- error = 1;
- }
- else if (ACE_OS::bind (this->get_handle (),
- (sockaddr *) local_sap.get_addr (),
- local_sap.get_size ()) == -1)
- error = 1;
-
- if (error != 0
- || ACE_OS::listen (this->get_handle (),
- backlog) == -1)
- {
- error = 1;
- this->close ();
- }
-
- return error ? -1 : 0;
+ ACE_TRACE ("ACE_SOCK_Acceptor::dump");
}
int
@@ -264,19 +230,15 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap,
int protocol)
{
ACE_TRACE ("ACE_SOCK_Acceptor::open");
-
- if (ACE_SOCK::open (SOCK_STREAM,
- protocol_family,
- protocol,
- protocolinfo,
- g,
- flags,
- reuse_addr) == -1)
- return -1;
- else
- return this->shared_open (local_sap,
- protocol_family,
- backlog);
+ ACE_UNUSED_ARG (local_sap);
+ ACE_UNUSED_ARG (protocolinfo);
+ ACE_UNUSED_ARG (g);
+ ACE_UNUSED_ARG (flags);
+ ACE_UNUSED_ARG (reuse_addr);
+ ACE_UNUSED_ARG (protocol_family);
+ ACE_UNUSED_ARG (backlog);
+ ACE_UNUSED_ARG (protocol);
+ ACE_NOTSUP_RETURN (-1);
}
ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap,
@@ -312,33 +274,55 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap,
int protocol)
{
ACE_TRACE ("ACE_SOCK_Acceptor::open");
+ int error = 0;
if (ACE_SOCK::open (SOCK_STREAM,
protocol_family,
protocol,
reuse_addr) == -1)
- return -1;
- else
- return this->shared_open (local_sap,
- protocol_family,
- backlog);
-}
+ error = 1;
-// General purpose routine for performing server ACE_SOCK creation.
+ else if (protocol_family == PF_INET)
+ {
+ sockaddr_in local_inet_addr;
+ ACE_OS::memset ((void *) &local_inet_addr,
+ 0,
+ sizeof local_inet_addr);
-ACE_SOCK_Acceptor::ACE_SOCK_Acceptor (const ACE_Addr &local_sap,
- int reuse_addr,
- int protocol_family,
- int backlog,
- int protocol)
-{
- ACE_TRACE ("ACE_SOCK_Acceptor::ACE_SOCK_Acceptor");
- if (this->open (local_sap,
- reuse_addr,
- protocol_family,
- backlog,
- protocol) == -1)
- ACE_ERROR ((LM_ERROR,
- ASYS_TEXT ("%p\n"),
- ASYS_TEXT ("ACE_SOCK_Acceptor")));
+ if (local_sap == ACE_Addr::sap_any)
+ {
+ local_inet_addr.sin_port = 0;
+ local_inet_addr.sin_addr.s_addr = htonl (INADDR_ANY);
+ }
+ else
+ local_inet_addr = *(sockaddr_in *) local_sap.get_addr ();
+
+ if (local_inet_addr.sin_port == 0)
+ {
+ if (ACE::bind_port (this->get_handle (),
+ local_inet_addr.sin_addr.s_addr) == -1)
+ error = 1;
+ }
+ else
+ {
+ if (ACE_OS::bind (this->get_handle (),
+ ACE_reinterpret_cast (sockaddr *,
+ &local_inet_addr),
+ sizeof local_inet_addr) == -1)
+ error = 1;
+ }
+ }
+ else if (ACE_OS::bind (this->get_handle (),
+ (sockaddr *) local_sap.get_addr (),
+ local_sap.get_size ()) == -1)
+ error = 1;
+
+ if (error || ACE_OS::listen (this->get_handle (),
+ backlog) == -1)
+ {
+ error = 1;
+ this->close ();
+ }
+
+ return error ? -1 : 0;
}