3 //=============================================================================
9 //=============================================================================
12 #ifndef ACE_SOCK_CODGRAM_H
13 #define ACE_SOCK_CODGRAM_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/ACE_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/SOCK_IO.h"
24 #include "ace/INET_Addr.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 * @class ACE_SOCK_CODgram
31 * @brief Defines the member functions for the ACE_SOCK connected
32 * datagram abstraction.
34 class ACE_Export ACE_SOCK_CODgram
: public ACE_SOCK_IO
37 /// Default constructor.
41 * Constructor with addresses specified. Calls open().
42 * This constructor binds and/or connects to a specified address,
43 * optionally binding an unused port number.
45 * @param remote_sap The remote address.
46 * @param local_sap The local address.
47 * @param protocol_family The protocol family for the new socket. If
48 * either @p remote_sap or @p local_sap is
49 * specified (i.e., not ACE_Addr::sap_any) its
50 * address type is used instead of this value.
51 * If both addresses are specified, their address
52 * types must match. If neither address is specified,
53 * the platform's default IP address type is used.
54 * @param protocol Protocol value for the new socket.
55 * @param reuse_addr Reuse the local address or not.
57 * There are four possible combinations of remote_sap and local_sap. The
58 * behavior in these combinations is:
60 * @li <b>remote_addr == ACE_Addr::sap_any && local_addr == ACE_Addr::sap_any:</b>
61 * If @p protocol_family specifies PF_INET or PF_INET6,
62 * bind the local address to a randomly generated port number.
64 * @li <b>remote_addr == ACE_Addr::sap_any && local_addr != ACE_Addr::sap_any:</b>
65 * Bind the local address (used primarily by servers).
67 * @li <b>remote_addr != ACE_Addr::sap_any && local_addr == ACE_Addr::sap_any:</b>
68 * Connect to the remote address without binding a local address
69 * (used primarily by clients).
71 * @li <b>remote_addr != ACE_Addr::sap_any && local_addr != ACE_Addr::sap_any:</b>
72 * Bind to the local address and connect to the remote address.
74 ACE_SOCK_CODgram (const ACE_Addr
&remote_sap
,
75 const ACE_Addr
&local_sap
= ACE_Addr::sap_any
,
76 int protocol_family
= ACE_PROTOCOL_FAMILY_INET
,
83 // Initiate a connected dgram.
86 * Initiate a connected datagram socket, optionally binding an
89 * @param remote_sap The remote address.
90 * @param local_sap The local address.
91 * @param protocol_family The protocol family for the new socket. If
92 * either @p remote_sap or @p local_sap is
93 * specified (i.e., not ACE_Addr::sap_any) its
94 * address type is used instead of this value.
95 * If both addresses are specified, their address
96 * types must match. If neither address is specified,
97 * the platform's default IP address type is used.
98 * @param protocol Protocol value for the new socket.
99 * @param reuse_addr Reuse the local address or not.
101 * There are four possible combinations of remote_sap and local_sap. The
102 * behavior in these combinations is:
104 * @li <b>remote_addr == ACE_Addr::sap_any && local_addr == ACE_Addr::sap_any:</b>
105 * If @p protocol_family specifies PF_INET or PF_INET6,
106 * bind the local address to a randomly generated port number.
108 * @li <b>remote_addr == ACE_Addr::sap_any && local_addr != ACE_Addr::sap_any:</b>
109 * Bind the local address (used primarily by servers).
111 * @li <b>remote_addr != ACE_Addr::sap_any && local_addr == ACE_Addr::sap_any:</b>
112 * Connect to the remote address without binding a local address
113 * (used primarily by clients).
115 * @li <b>remote_addr != ACE_Addr::sap_any && local_addr != ACE_Addr::sap_any:</b>
116 * Bind to the local address and connect to the remote address.
118 int open (const ACE_Addr
&remote_sap
,
119 const ACE_Addr
&local_sap
= ACE_Addr::sap_any
,
120 int protocol_family
= ACE_PROTOCOL_FAMILY_INET
,
125 typedef ACE_INET_Addr PEER_ADDR
;
127 /// Dump the state of an object.
130 /// Declare the dynamic allocation hooks.
131 ACE_ALLOC_HOOK_DECLARE
;
134 ACE_END_VERSIONED_NAMESPACE_DECL
136 #if defined (__ACE_INLINE__)
137 #include "ace/SOCK_CODgram.inl"
138 #endif /* __ACE_INLINE__ */
140 #include /**/ "ace/post.h"
141 #endif /* ACE_SOCK_CODGRAM_H */