2 #include "ace/Log_Category.h"
3 #if defined (ACE_HAS_ALLOC_HOOKS)
4 # include "ace/Malloc_Base.h"
5 #endif /* ACE_HAS_ALLOC_HOOKS */
7 #if !defined (__ACE_INLINE__)
8 #include "ace/SOCK.inl"
9 #endif /* __ACE_INLINE__ */
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 ACE_ALLOC_HOOK_DEFINE(ACE_SOCK
)
16 ACE_SOCK::dump () const
18 #if defined (ACE_HAS_DUMP)
19 ACE_TRACE ("ACE_SOCK::dump");
20 #endif /* ACE_HAS_DUMP */
25 // ACE_TRACE ("ACE_SOCK::ACE_SOCK");
28 // Returns information about the remote peer endpoint (if there is
32 ACE_SOCK::get_remote_addr (ACE_Addr
&sa
) const
34 ACE_TRACE ("ACE_SOCK::get_remote_addr");
36 int len
= sa
.get_size ();
37 sockaddr
*addr
= reinterpret_cast<sockaddr
*> (sa
.get_addr ());
39 if (ACE_OS::getpeername (this->get_handle (),
45 sa
.set_type (addr
->sa_family
);
50 ACE_SOCK::get_local_addr (ACE_Addr
&sa
) const
52 ACE_TRACE ("ACE_SOCK::get_local_addr");
54 int len
= sa
.get_size ();
55 sockaddr
*addr
= reinterpret_cast<sockaddr
*> (sa
.get_addr ());
57 if (ACE_OS::getsockname (this->get_handle (),
62 sa
.set_type (addr
->sa_family
);
67 // Close down a ACE_SOCK.
72 ACE_TRACE ("ACE_SOCK::close");
75 if (this->get_handle () != ACE_INVALID_HANDLE
)
77 result
= ACE_OS::closesocket (this->get_handle ());
78 this->set_handle (ACE_INVALID_HANDLE
);
84 ACE_SOCK::open (int type
,
89 ACE_TRACE ("ACE_SOCK::open");
92 this->set_handle (ACE_OS::socket (protocol_family
,
96 if (this->get_handle () == ACE_INVALID_HANDLE
)
98 else if (protocol_family
!= PF_UNIX
100 && this->set_option (SOL_SOCKET
,
111 // General purpose constructor for performing server ACE_SOCK
114 ACE_SOCK::ACE_SOCK (int type
,
119 // ACE_TRACE ("ACE_SOCK::ACE_SOCK");
120 if (this->open (type
,
124 ACELIB_ERROR ((LM_ERROR
,
126 ACE_TEXT ("ACE_SOCK::ACE_SOCK")));
130 ACE_SOCK::open (int type
,
133 ACE_Protocol_Info
*protocolinfo
,
138 ACE_TRACE ("ACE_SOCK::open");
140 this->set_handle (ACE_OS::socket (protocol_family
,
148 if (this->get_handle () == ACE_INVALID_HANDLE
)
151 && this->set_option (SOL_SOCKET
,
163 ACE_SOCK::ACE_SOCK (int type
,
166 ACE_Protocol_Info
*protocolinfo
,
171 // ACE_TRACE ("ACE_SOCK::ACE_SOCK");
172 if (this->open (type
,
179 ACELIB_ERROR ((LM_ERROR
,
181 ACE_TEXT ("ACE_SOCK::ACE_SOCK")));
184 ACE_END_VERSIONED_NAMESPACE_DECL