[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / LSOCK_Acceptor.cpp
blob0259697ea5fc1a172c58c62de4dd8b288ae77bd8
1 // $Id: LSOCK_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/LSOCK_Acceptor.h"
5 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
7 #include "ace/Log_Msg.h"
8 #include "ace/OS_NS_unistd.h"
9 #include "ace/OS_NS_sys_socket.h"
11 ACE_RCSID(ace, LSOCK_Acceptor, "$Id: LSOCK_Acceptor.cpp 80826 2008-03-04 14:51:23Z wotte $")
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Acceptor)
17 // Return the local endpoint address.
19 int
20 ACE_LSOCK_Acceptor::get_local_addr (ACE_Addr &a) const
22 ACE_TRACE ("ACE_LSOCK_Acceptor::get_local_addr");
24 ACE_UNIX_Addr& target = dynamic_cast<ACE_UNIX_Addr &> (a);
26 target = this->local_addr_;
28 return 0;
31 void
32 ACE_LSOCK_Acceptor::dump (void) const
34 #if defined (ACE_HAS_DUMP)
35 ACE_TRACE ("ACE_LSOCK_Acceptor::dump");
37 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
38 this->local_addr_.dump ();
39 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
40 #endif /* ACE_HAS_DUMP */
43 // Do nothing routine for constructor.
45 ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor (void)
47 ACE_TRACE ("ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor");
50 int
51 ACE_LSOCK_Acceptor::open (const ACE_Addr &remote_sap,
52 int reuse_addr,
53 int protocol_family,
54 int backlog,
55 int protocol)
57 ACE_TRACE ("ACE_LSOCK_Acceptor::open");
58 this->local_addr_ = *((ACE_UNIX_Addr *) &remote_sap); // This is a gross hack...
59 return ACE_SOCK_Acceptor::open (remote_sap, reuse_addr,
60 protocol_family, backlog, protocol);
63 // General purpose routine for performing server ACE_SOCK creation.
65 ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor (const ACE_Addr &remote_sap,
66 int reuse_addr,
67 int protocol_family,
68 int backlog,
69 int protocol)
71 ACE_TRACE ("ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor");
72 if (this->open (remote_sap,
73 reuse_addr,
74 protocol_family,
75 backlog,
76 protocol) == -1)
77 ACE_ERROR ((LM_ERROR,
78 "ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor"));
81 // General purpose routine for accepting new connections.
83 int
84 ACE_LSOCK_Acceptor::accept (ACE_LSOCK_Stream &new_stream,
85 ACE_Addr *remote_addr,
86 ACE_Time_Value *timeout,
87 int restart,
88 int reset_new_handle) const
90 ACE_TRACE ("ACE_LSOCK_Acceptor::accept");
92 int in_blocking_mode = 0;
93 if (this->shared_accept_start (timeout,
94 restart,
95 in_blocking_mode) == -1)
96 return -1;
97 else
99 sockaddr *addr = 0;
100 int len = 0;
102 if (remote_addr != 0)
104 len = remote_addr->get_size ();
105 addr = (sockaddr *) remote_addr->get_addr ();
109 new_stream.set_handle (ACE_OS::accept (this->get_handle (),
110 addr,
111 &len));
112 while (new_stream.get_handle () == ACE_INVALID_HANDLE
113 && restart != 0
114 && errno == EINTR
115 && timeout == 0);
117 // Reset the size of the addr, which is only necessary for UNIX
118 // domain sockets.
119 if (new_stream.get_handle () != ACE_INVALID_HANDLE
120 && remote_addr != 0)
121 remote_addr->set_size (len);
124 return this->shared_accept_finish (new_stream,
125 in_blocking_mode,
126 reset_new_handle);
129 // Close down the UNIX domain stream and remove the rendezvous point
130 // from the file system.
133 ACE_LSOCK_Acceptor::remove (void)
135 ACE_TRACE ("ACE_LSOCK_Acceptor::remove");
136 int result = this->close ();
137 return ACE_OS::unlink (this->local_addr_.get_path_name ()) == -1
138 || result == -1 ? -1 : 0;
141 ACE_END_VERSIONED_NAMESPACE_DECL
143 #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */