1 #include "ace/LSOCK_Stream.h"
2 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
4 #include "ace/Log_Category.h"
5 #include "ace/OS_NS_sys_socket.h"
6 #if defined (ACE_HAS_ALLOC_HOOKS)
7 # include "ace/Malloc_Base.h"
8 #endif /* ACE_HAS_ALLOC_HOOKS */
10 #if !defined (__ACE_INLINE__)
11 #include "ace/LSOCK_Stream.inl"
12 #endif /* __ACE_INLINE__ */
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
16 ACE_ALLOC_HOOK_DEFINE(ACE_LSOCK_Stream
)
19 ACE_LSOCK_Stream::get_local_addr (ACE_Addr
&addr
) const
21 ACE_TRACE ("ACE_LSOCK_Stream::get_local_addr");
23 // Perform the downcast since <addr> had better be an
25 ACE_UNIX_Addr
*rhs_unix_addr
= dynamic_cast<ACE_UNIX_Addr
*> (&addr
);
26 ACE_UNIX_Addr lhs_unix_addr
;
28 if (rhs_unix_addr
== 0)
30 else if (ACE_SOCK::get_local_addr (lhs_unix_addr
) == -1)
34 *rhs_unix_addr
= lhs_unix_addr
;
40 ACE_LSOCK_Stream::get_remote_addr (ACE_Addr
&addr
) const
42 ACE_TRACE ("ACE_LSOCK_Stream::get_remote_addr");
44 return this->get_local_addr (addr
);
48 ACE_LSOCK_Stream::dump () const
50 ACE_TRACE ("ACE_LSOCK_Stream::dump");
52 ACELIB_DEBUG ((LM_DEBUG
, ACE_BEGIN_DUMP
, this));
53 ACE_SOCK_Stream::dump ();
55 ACELIB_DEBUG ((LM_DEBUG
, ACE_END_DUMP
));
58 #if defined (ACE_HAS_MSG)
60 // Send a readv-style vector of buffers, along with an open I/O
64 ACE_LSOCK_Stream::send_msg (const iovec iov
[],
68 ACE_TRACE ("ACE_LSOCK_Stream::send_msg");
70 #if !defined (ACE_LACKS_SENDMSG) && defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
71 char cmsgbuf
[ACE_BSD_CONTROL_MSG_LEN
];
72 cmsghdr
*cmsgptr
= (cmsghdr
*) cmsgbuf
;
73 #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
75 send_msg
.msg_iov
= const_cast <iovec
*> (iov
);
76 send_msg
.msg_iovlen
= n
;
77 send_msg
.msg_name
= 0;
78 send_msg
.msg_namelen
= 0;
80 #if defined (ACE_LACKS_SENDMSG)
81 ACE_UNUSED_ARG (handle
);
83 # if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
84 cmsgptr
->cmsg_level
= SOL_SOCKET
;
85 cmsgptr
->cmsg_type
= SCM_RIGHTS
;
86 cmsgptr
->cmsg_len
= sizeof cmsgbuf
;
87 send_msg
.msg_control
= cmsgbuf
;
88 send_msg
.msg_controllen
= sizeof cmsgbuf
;
89 *(ACE_HANDLE
*) CMSG_DATA (cmsgptr
) = handle
;
90 send_msg
.msg_flags
= 0 ;
92 send_msg
.msg_accrights
= (char *) &handle
;
93 send_msg
.msg_accrightslen
= sizeof handle
;
94 # endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
95 #endif /* ACE_LACKS_SENDMSG */
97 return ACE_OS::sendmsg (this->ACE_SOCK_Stream::get_handle (),
101 // Read a readv-style vector of buffers, along with an open I/O
105 ACE_LSOCK_Stream::recv_msg (iovec iov
[],
109 ACE_TRACE ("ACE_LSOCK_Stream::recv_msg");
111 #if !defined (ACE_LACKS_SENDMSG) && defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
112 char cmsgbuf
[ACE_BSD_CONTROL_MSG_LEN
];
113 cmsghdr
*cmsgptr
= (cmsghdr
*) cmsgbuf
;
114 #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
116 recv_msg
.msg_iov
= (iovec
*) iov
;
117 recv_msg
.msg_iovlen
= n
;
118 recv_msg
.msg_name
= 0;
119 recv_msg
.msg_namelen
= 0;
121 #if defined (ACE_LACKS_SENDMSG)
122 ACE_UNUSED_ARG (handle
);
123 #elif defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
124 recv_msg
.msg_control
= cmsgbuf
;
125 recv_msg
.msg_controllen
= sizeof cmsgbuf
;
126 ssize_t result
= ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (),
128 handle
= *(ACE_HANDLE
*) CMSG_DATA (cmsgptr
) ;
131 recv_msg
.msg_accrights
= (char *) &handle
;
132 recv_msg
.msg_accrightslen
= sizeof handle
;
133 #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */ /* ACE_LACKS_SENDMSG */
135 #if defined ACE_LACKS_SENDMSG || !defined ACE_HAS_4_4BSD_SENDMSG_RECVMSG
136 return ACE_OS::recvmsg (this->ACE_SOCK_Stream::get_handle (),
140 #endif /* ACE_HAS_MSG */
142 ACE_END_VERSIONED_NAMESPACE_DECL
144 #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */