00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file SOCK_CODgram.h 00006 * 00007 * $Id: SOCK_CODgram.h 81509 2008-04-28 22:00:49Z shuston $ 00008 * 00009 * @author Doug Schmidt 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef ACE_SOCK_CODGRAM_H 00015 #define ACE_SOCK_CODGRAM_H 00016 #include /**/ "ace/pre.h" 00017 00018 #include /**/ "ace/ACE_export.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "ace/SOCK_IO.h" 00025 #include "ace/Addr.h" 00026 #include "ace/INET_Addr.h" 00027 00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00029 00030 /** 00031 * @class ACE_SOCK_CODgram 00032 * 00033 * @brief Defines the member functions for the ACE_SOCK connected 00034 * datagram abstraction. 00035 */ 00036 class ACE_Export ACE_SOCK_CODgram : public ACE_SOCK_IO 00037 { 00038 public: 00039 /// Default constructor. 00040 ACE_SOCK_CODgram (void); 00041 00042 /** 00043 * Constructor with addresses specified. Calls open(). 00044 * This constructor binds and/or connects to a specified address, 00045 * optionally binding an unused port number. 00046 * 00047 * @param remote_sap The remote address. 00048 * @param local_sap The local address. 00049 * @param protocol_family The protocol family for the new socket. If 00050 * either @p remote_sap or @p local_sap is 00051 * specified (i.e., not ACE_Addr::sap_any) its 00052 * address type is used instead of this value. 00053 * If both addresses are specified, their address 00054 * types must match. If neither address is specified, 00055 * the platform's default IP address type is used. 00056 * @param protocol Protocol value for the new socket. 00057 * @param reuse_addr Reuse the local address or not. 00058 * 00059 * There are four possible combinations of remote_sap and local_sap. The 00060 * behavior in these combinations is: 00061 * 00062 * @li <b>remote_addr == ACE_Addr::sap_any && local_addr == ACE_Addr::sap_any:</b> 00063 * If @p protocol_family specifies PF_INET or PF_INET6, 00064 * bind the local address to a randomly generated port number. 00065 * 00066 * @li <b>remote_addr == ACE_Addr::sap_any && local_addr != ACE_Addr::sap_any:</b> 00067 * Bind the local address (used primarily by servers). 00068 * 00069 * @li <b>remote_addr != ACE_Addr::sap_any && local_addr == ACE_Addr::sap_any:</b> 00070 * Connect to the remote address without binding a local address 00071 * (used primarily by clients). 00072 * 00073 * @li <b>remote_addr != ACE_Addr::sap_any && local_addr != ACE_Addr::sap_any:</b> 00074 * Bind to the local address and connect to the remote address. 00075 */ 00076 ACE_SOCK_CODgram (const ACE_Addr &remote_sap, 00077 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00078 int protocol_family = ACE_PROTOCOL_FAMILY_INET, 00079 int protocol = 0, 00080 int reuse_addr = 0); 00081 00082 /// Default dtor. 00083 ~ACE_SOCK_CODgram (void); 00084 00085 // Initiate a connected dgram. 00086 00087 /** 00088 * Initiate a connected datagram socket, optionally binding an 00089 * unused port number. 00090 * 00091 * @param remote_sap The remote address. 00092 * @param local_sap The local address. 00093 * @param protocol_family The protocol family for the new socket. If 00094 * either @p remote_sap or @p local_sap is 00095 * specified (i.e., not ACE_Addr::sap_any) its 00096 * address type is used instead of this value. 00097 * If both addresses are specified, their address 00098 * types must match. If neither address is specified, 00099 * the platform's default IP address type is used. 00100 * @param protocol Protocol value for the new socket. 00101 * @param reuse_addr Reuse the local address or not. 00102 * 00103 * There are four possible combinations of remote_sap and local_sap. The 00104 * behavior in these combinations is: 00105 * 00106 * @li <b>remote_addr == ACE_Addr::sap_any && local_addr == ACE_Addr::sap_any:</b> 00107 * If @p protocol_family specifies PF_INET or PF_INET6, 00108 * bind the local address to a randomly generated port number. 00109 * 00110 * @li <b>remote_addr == ACE_Addr::sap_any && local_addr != ACE_Addr::sap_any:</b> 00111 * Bind the local address (used primarily by servers). 00112 * 00113 * @li <b>remote_addr != ACE_Addr::sap_any && local_addr == ACE_Addr::sap_any:</b> 00114 * Connect to the remote address without binding a local address 00115 * (used primarily by clients). 00116 * 00117 * @li <b>remote_addr != ACE_Addr::sap_any && local_addr != ACE_Addr::sap_any:</b> 00118 * Bind to the local address and connect to the remote address. 00119 */ 00120 int open (const ACE_Addr &remote_sap, 00121 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00122 int protocol_family = ACE_PROTOCOL_FAMILY_INET, 00123 int protocol = 0, 00124 int reuse_addr = 0); 00125 00126 // = Meta-type info. 00127 typedef ACE_INET_Addr PEER_ADDR; 00128 00129 /// Dump the state of an object. 00130 void dump (void) const; 00131 00132 /// Declare the dynamic allocation hooks. 00133 ACE_ALLOC_HOOK_DECLARE; 00134 }; 00135 00136 ACE_END_VERSIONED_NAMESPACE_DECL 00137 00138 #if defined (__ACE_INLINE__) 00139 #include "ace/SOCK_CODgram.inl" 00140 #endif /* __ACE_INLINE__ */ 00141 00142 #include /**/ "ace/post.h" 00143 #endif /* ACE_SOCK_CODGRAM_H */