Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / OS_NS_sys_socket.h
blob17ef39ac53023eed5c017ce3cc5f02ee0c72edf5
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_NS_sys_socket.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 //=============================================================================
13 #ifndef ACE_OS_NS_SYS_SOCKET_H
14 # define ACE_OS_NS_SYS_SOCKET_H
16 # include /**/ "ace/pre.h"
18 # include "ace/config-all.h"
20 # if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 # endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/os_include/sys/os_socket.h"
25 #include "ace/os_include/net/os_if.h"
26 #include "ace/OS_NS_stropts.h"
27 #include /**/ "ace/ACE_export.h"
29 #if defined (ACE_EXPORT_MACRO)
30 # undef ACE_EXPORT_MACRO
31 #endif
32 #define ACE_EXPORT_MACRO ACE_Export
34 /// These are available values for the @a how argument to ACE_OS::shutdown().
35 #if defined (SD_RECEIVE)
36 #define ACE_SHUTDOWN_READ SD_RECEIVE
37 #elif defined (SHUT_RD)
38 #define ACE_SHUTDOWN_READ SHUT_RD
39 #else
40 #define ACE_SHUTDOWN_READ 0
41 #endif /* SD_RECEIVE */
43 #if defined (SD_SEND)
44 #define ACE_SHUTDOWN_WRITE SD_SEND
45 #elif defined (SHUT_WR)
46 #define ACE_SHUTDOWN_WRITE SHUT_WR
47 #else
48 #define ACE_SHUTDOWN_WRITE 1
49 #endif /* SD_SEND */
51 #if defined (SD_BOTH)
52 #define ACE_SHUTDOWN_BOTH SD_BOTH
53 #elif defined (SHUT_RDWR)
54 #define ACE_SHUTDOWN_BOTH SHUT_RDWR
55 #else
56 #define ACE_SHUTDOWN_BOTH 2
57 #endif /* SD_BOTH */
59 #if defined (IP_RECVDSTADDR)
60 #define ACE_RECVPKTINFO IP_RECVDSTADDR
61 #elif defined (IP_PKTINFO)
62 #define ACE_RECVPKTINFO IP_PKTINFO
63 #endif
65 #if defined (ACE_HAS_IPV6)
66 #if defined (IPV6_RECVPKTINFO)
67 #define ACE_RECVPKTINFO6 IPV6_RECVPKTINFO
68 #endif
69 #endif
71 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
73 class ACE_Accept_QoS_Params;
74 class ACE_QoS_Params;
76 namespace ACE_OS
78 # if defined (ACE_WIN32)
79 /// Keeps track of whether we've already initialized WinSock...
80 extern ACE_Export int socket_initialized_;
81 # endif /* ACE_WIN32 */
83 //@{ @name A set of wrappers for sockets.
84 /// BSD-style @c accept (no QoS).
85 ACE_NAMESPACE_INLINE_FUNCTION
86 ACE_HANDLE accept (ACE_HANDLE handle,
87 struct sockaddr *addr,
88 int *addrlen);
90 /**
91 * QoS-enabled @c accept, which passes @a qos_params to @c accept. If
92 * the OS platform doesn't support QoS-enabled @c accept then the
93 * @a qos_params are ignored and the BSD-style @c accept is called.
95 extern ACE_Export
96 ACE_HANDLE accept (ACE_HANDLE handle,
97 struct sockaddr *addr,
98 int *addrlen,
99 const ACE_Accept_QoS_Params &qos_params);
101 ACE_NAMESPACE_INLINE_FUNCTION
102 int bind (ACE_HANDLE s,
103 struct sockaddr *name,
104 int namelen);
106 /// Takes care of windows specific requirement to call closesocket
107 ACE_NAMESPACE_INLINE_FUNCTION
108 int closesocket (ACE_HANDLE s);
110 /// BSD-style @c connect (no QoS).
111 ACE_NAMESPACE_INLINE_FUNCTION
112 int connect (ACE_HANDLE handle,
113 struct sockaddr *addr,
114 int addrlen);
117 * QoS-enabled @c connect, which passes @a qos_params to @c connect.
118 * If the OS platform doesn't support QoS-enabled @c connect then the
119 * @a qos_params are ignored and the BSD-style @c connect is called.
121 extern ACE_Export
122 int connect (ACE_HANDLE handle,
123 const sockaddr *addr,
124 int addrlen,
125 const ACE_QoS_Params &qos_params);
127 /// Retrieve information about available transport protocols
128 /// installed on the local machine. Windows specific...
129 ACE_NAMESPACE_INLINE_FUNCTION
130 int enum_protocols (int *protocols,
131 ACE_Protocol_Info *protocol_buffer,
132 u_long *buffer_length);
134 ACE_NAMESPACE_INLINE_FUNCTION
135 int getpeername (ACE_HANDLE handle,
136 struct sockaddr *addr,
137 int *addrlen);
139 ACE_NAMESPACE_INLINE_FUNCTION
140 int getsockname (ACE_HANDLE handle,
141 struct sockaddr *addr,
142 int *addrlen);
143 ACE_NAMESPACE_INLINE_FUNCTION
144 int getsockopt (ACE_HANDLE handle,
145 int level,
146 int optname,
147 char *optval,
148 int *optlen);
150 /// Joins a leaf node into a QoS-enabled multi-point session.
151 extern ACE_Export
152 ACE_HANDLE join_leaf (ACE_HANDLE socket,
153 const sockaddr *name,
154 int namelen,
155 const ACE_QoS_Params &qos_params);
157 ACE_NAMESPACE_INLINE_FUNCTION
158 int listen (ACE_HANDLE handle,
159 int backlog);
161 ACE_NAMESPACE_INLINE_FUNCTION
162 ssize_t recv (ACE_HANDLE handle,
163 char *buf,
164 size_t len,
165 int flags = 0);
167 ACE_NAMESPACE_INLINE_FUNCTION
168 ssize_t recvfrom (ACE_HANDLE handle,
169 char *buf,
170 size_t len,
171 int flags,
172 struct sockaddr *addr,
173 int *addrlen);
175 ACE_NAMESPACE_INLINE_FUNCTION
176 ssize_t recvfrom (ACE_HANDLE handle,
177 iovec *buffers,
178 int buffer_count,
179 size_t &number_of_bytes_recvd,
180 int &flags,
181 struct sockaddr *addr,
182 int *addrlen,
183 ACE_OVERLAPPED *overlapped,
184 ACE_OVERLAPPED_COMPLETION_FUNC func);
186 ACE_NAMESPACE_INLINE_FUNCTION
187 ssize_t recvmsg (ACE_HANDLE handle,
188 struct msghdr *msg,
189 int flags);
191 #if !defined ACE_LACKS_RECVMSG && defined ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2
192 extern ACE_Export
193 int recvmsg_win32_i (ACE_HANDLE handle,
194 msghdr *msg,
195 int flags,
196 unsigned long &bytes_received);
197 #endif
199 ACE_NAMESPACE_INLINE_FUNCTION
200 ssize_t recvv (ACE_HANDLE handle,
201 iovec *iov,
202 int iovlen);
204 ACE_NAMESPACE_INLINE_FUNCTION
205 ssize_t send (ACE_HANDLE handle,
206 const char *buf,
207 size_t len,
208 int flags = 0);
210 /// internal function used by send when an ENOBUFS condition
211 /// requires a buffer to do a partial send
212 extern ACE_Export
213 ssize_t send_partial_i (ACE_HANDLE handle,
214 const char *buf,
215 size_t len,
216 int flags);
218 ACE_NAMESPACE_INLINE_FUNCTION
219 ssize_t sendmsg (ACE_HANDLE handle,
220 const struct msghdr *msg,
221 int flags);
223 #if !defined ACE_LACKS_RECVMSG && defined ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2
224 extern ACE_Export
225 int sendmsg_win32_i (ACE_HANDLE handle,
226 msghdr const *msg,
227 int flags,
228 unsigned long &bytes_sent);
229 #endif
231 ACE_NAMESPACE_INLINE_FUNCTION
232 ssize_t sendto (ACE_HANDLE handle,
233 const char *buf,
234 size_t len,
235 int flags,
236 const struct sockaddr *addr,
237 int addrlen);
239 ACE_NAMESPACE_INLINE_FUNCTION
240 ssize_t sendto (ACE_HANDLE handle,
241 const iovec *buffers,
242 int buffer_count,
243 size_t &number_of_bytes_sent,
244 int flags,
245 const struct sockaddr *addr,
246 int addrlen,
247 ACE_OVERLAPPED *overlapped,
248 ACE_OVERLAPPED_COMPLETION_FUNC func);
250 ACE_NAMESPACE_INLINE_FUNCTION
251 ssize_t sendv (ACE_HANDLE handle,
252 const iovec *iov,
253 int iovcnt);
255 /// internal function used by sendv when an ENOBUFS condition
256 /// requires a buffer to do a partial send
257 extern ACE_Export
258 ssize_t sendv_partial_i (ACE_HANDLE handle,
259 const iovec *iov,
260 int iovcnt);
262 /// Manipulate the options associated with a socket.
263 ACE_NAMESPACE_INLINE_FUNCTION
264 int setsockopt (ACE_HANDLE handle,
265 int level,
266 int optname,
267 const char *optval,
268 int optlen);
270 ACE_NAMESPACE_INLINE_FUNCTION
271 int shutdown (ACE_HANDLE handle,
272 int how);
274 ACE_NAMESPACE_INLINE_FUNCTION
275 unsigned int if_nametoindex (const char *ifname);
277 ACE_NAMESPACE_INLINE_FUNCTION
278 char *if_indextoname (unsigned int ifindex, char *ifname);
280 ACE_NAMESPACE_INLINE_FUNCTION
281 struct if_nameindex *if_nameindex ();
283 ACE_NAMESPACE_INLINE_FUNCTION
284 void if_freenameindex (struct if_nameindex *ptr);
286 /// Initialize WinSock before first use (e.g., when a DLL is first
287 /// loaded or the first use of a socket() call.
288 extern ACE_Export
289 int socket_init (int version_high = 1,
290 int version_low = 1);
292 /// Finalize WinSock after last use (e.g., when a DLL is unloaded).
293 extern ACE_Export
294 int socket_fini ();
296 /// Create a BSD-style socket (no QoS).
297 ACE_NAMESPACE_INLINE_FUNCTION
298 ACE_HANDLE socket (int protocol_family,
299 int type,
300 int proto);
302 /// Create a QoS-enabled socket. If the OS platform doesn't support
303 /// QoS-enabled <socket> then the BSD-style <socket> is called.
304 ACE_NAMESPACE_INLINE_FUNCTION
305 ACE_HANDLE socket (int protocol_family,
306 int type,
307 int proto,
308 ACE_Protocol_Info *protocolinfo,
309 ACE_SOCK_GROUP g,
310 u_long flags);
312 ACE_NAMESPACE_INLINE_FUNCTION
313 int socketpair (int domain,
314 int type,
315 int protocol,
316 ACE_HANDLE sv[2]);
317 } /* namespace ACE_OS */
319 ACE_END_VERSIONED_NAMESPACE_DECL
321 # if defined (ACE_HAS_INLINED_OSCALLS)
322 # if defined (ACE_INLINE)
323 # undef ACE_INLINE
324 # endif /* ACE_INLINE */
325 # define ACE_INLINE inline
326 # include "ace/OS_NS_sys_socket.inl"
327 # endif /* ACE_HAS_INLINED_OSCALLS */
329 # include /**/ "ace/post.h"
330 #endif /* ACE_OS_NS_SYS_SOCKET_H */