00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file LSOCK_CODgram.h 00006 * 00007 * $Id: LSOCK_CODgram.h 84419 2009-02-11 22:28:11Z shuston $ 00008 * 00009 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu> 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef ACE_LOCAL_SOCK_CODGRAM_H 00015 #define ACE_LOCAL_SOCK_CODGRAM_H 00016 #include /**/ "ace/pre.h" 00017 00018 #include /**/ "ace/config-all.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS) 00025 00026 #include "ace/LSOCK.h" 00027 #include "ace/SOCK_CODgram.h" 00028 #include "ace/Addr.h" 00029 00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00031 00032 /** 00033 * @class ACE_LSOCK_CODgram 00034 * 00035 * @brief Defines a fully specified (sometimes called "connected") UNIX-domain 00036 * datagram abstraction. 00037 * 00038 * ACE_LSOCK_CODgram provides a way to use a UNIX-domain datagram socket in 00039 * a situation where the local and peer addresses are fully known in advance. 00040 * The "connection-oriented" part of "CODgram" is a misnomer. There is no 00041 * connection used on this type of socket. It merely specifies that both 00042 * endpoint addresses are known in advance of use. Furthermore, this class 00043 * is more suited for use cases where a local endpoint wishes to communicate 00044 * with a single, known peer and may or may not have a specified local address. 00045 * 00046 * If your use case requires receiving datagrams from multiple peers without 00047 * previously known addresses, consider using ACE_LSOCK_Dgram instead. 00048 */ 00049 class ACE_Export ACE_LSOCK_CODgram : public ACE_SOCK_CODgram, public ACE_LSOCK 00050 { 00051 public: 00052 /// Default constructor; requires a call to open() prior to communication. 00053 ACE_LSOCK_CODgram (void); 00054 00055 /** 00056 * @name Initialization methods 00057 */ 00058 //@{ 00059 /** 00060 * Initialize a fully-specified datagram socket. 00061 * 00062 * @param remote_sap Remote/peer address. This should be an ACE_UNIX_Addr 00063 * object. It specifies where all sent datagrams will 00064 * be sent to. 00065 * @param local_sap Local address. The local address to receive datagrams 00066 * at. If not specified, an unused address is selected. 00067 * If specified, should be an ACE_UNIX_Addr object. 00068 * 00069 * @sa ACE_UNIX_Addr 00070 */ 00071 ACE_LSOCK_CODgram (const ACE_Addr &remote_sap, 00072 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00073 int protocol_family = PF_UNIX, 00074 int protocol = 0); 00075 00076 /** 00077 * Initialize a fully-specified datagram socket. 00078 * 00079 * @retval 0 if no error. 00080 * @retval -1 on error; check errno for an error reason. 00081 */ 00082 int open (const ACE_Addr &remote_sap, 00083 const ACE_Addr &local_sap = ACE_Addr::sap_any, 00084 int protocol_family = PF_UNIX, 00085 int protocol = 0); 00086 //@} 00087 00088 /// Get underlying handle. 00089 ACE_HANDLE get_handle (void) const; 00090 00091 /// Set underlying handle. 00092 void set_handle (ACE_HANDLE); 00093 00094 /// Dump the state of an object. 00095 void dump (void) const; 00096 00097 /// Declare the dynamic allocation hooks. 00098 ACE_ALLOC_HOOK_DECLARE; 00099 }; 00100 00101 ACE_END_VERSIONED_NAMESPACE_DECL 00102 00103 #if defined (__ACE_INLINE__) 00104 #include "ace/LSOCK_CODgram.inl" 00105 #endif /* __ACE_INLINE__ */ 00106 00107 #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */ 00108 #include /**/ "ace/post.h" 00109 #endif /* ACE_LOCAL_SOCK_CODGRAM_H */