00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file FIFO_Recv_Msg.h 00006 * 00007 * $Id: FIFO_Recv_Msg.h 80826 2008-03-04 14:51:23Z wotte $ 00008 * 00009 * @author Doug Schmidt 00010 */ 00011 //============================================================================= 00012 00013 00014 #ifndef ACE_FIFO_RECV_MSG_H 00015 #define ACE_FIFO_RECV_MSG_H 00016 #include /**/ "ace/pre.h" 00017 00018 #include "ace/FIFO_Recv.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00025 00026 // Forward decls 00027 class ACE_Str_Buf; 00028 00029 /** 00030 * @class ACE_FIFO_Recv_Msg 00031 * 00032 * @brief Receiver side for the record oriented C++ wrapper for UNIX FIFOs. 00033 * 00034 * This method works slightly differently on platforms with the 00035 * @c ACE_HAS_STREAM_PIPES configuration setting than those without. 00036 * With ACE_HAS_STREAM_PIPES, the @c getmsg() system function is used 00037 * and it preserves message boundaries internally. Without 00038 * @c ACE_HAS_STREAM_PIPES, the message boundaries are emulated by 00039 * this class and ACE_FIFO_Send_Msg cooperating. The sending class 00040 * first writes an integer number of bytes in the message, then the 00041 * message. ACE_FIFO_Recv_Msg reads the count, then the data. 00042 * The operational differences occur primarily when a message is larger 00043 * than what a caller of this class requests. See recv() for details. 00044 */ 00045 class ACE_Export ACE_FIFO_Recv_Msg : public ACE_FIFO_Recv 00046 { 00047 public: 00048 // = Initialization methods. 00049 /// Default constructor. 00050 ACE_FIFO_Recv_Msg (void); 00051 00052 /// Open up a record-oriented named pipe for reading. 00053 ACE_FIFO_Recv_Msg (const ACE_TCHAR *rendezvous, 00054 int flags = O_CREAT | O_RDONLY, 00055 mode_t perms = ACE_DEFAULT_FILE_PERMS, 00056 int persistent = 1, 00057 LPSECURITY_ATTRIBUTES sa = 0); 00058 00059 /// Open up a record-oriented named pipe for reading. 00060 int open (const ACE_TCHAR *rendezvous, 00061 int flags = O_CREAT | O_RDONLY, 00062 mode_t perms = ACE_DEFAULT_FILE_PERMS, 00063 int persistent = 1, 00064 LPSECURITY_ATTRIBUTES sa = 0); 00065 00066 /// Receive a message based on attributes in an ACE_Str_Buf. 00067 /** 00068 * @param msg Reference to an ACE_Str_Buf whose @c buf member points 00069 * to the memory to receive the data and @c maxlen member 00070 * contains the maximum number of bytes to receive. 00071 * On return after successfully reading data, the 00072 * @c len member contains the number of bytes received and 00073 * placed in the buffer pointed to by @c msg.buf. 00074 * 00075 * @retval -1 Error; consult @c errno for specific error number. 00076 * @return If the @c ACE_HAS_STREAM_PIPES configuration setting is 00077 * defined, the return value is the number of bytes received 00078 * in the message and will be the same as @c buf.len. 00079 * The return value from the @c getmsg() system function 00080 * is discarded. 00081 * If @c ACE_HAS_STREAM_PIPES is not defined, the number 00082 * of bytes in the message read from the FIFO is returned. 00083 * If the message is larger than the maximum length 00084 * requested in @c msg.maxlen, the return value reflects 00085 * the entire message length, and the @c msg.len member 00086 * reflects how many bytes were actually placed in the 00087 * caller's buffer. Any part of the message longer than 00088 * @c msg.maxlen is discarded. 00089 */ 00090 ssize_t recv (ACE_Str_Buf &msg); 00091 00092 /// Receive a message based on buffer pointer and maximum size. 00093 /** 00094 * @param buf Pointer to the memory to receive the data. 00095 * @param len The maximum number of bytes to receive. 00096 * 00097 * @retval -1 Error; consult @c errno for specific error number. 00098 * @return The number of bytes received in the message. For messages 00099 * that are larger than the requested maximum size, the 00100 * behavior is different depending on the @c ACE_HAS_STREAM_PIPES 00101 * configuration setting. With @c ACE_HAS_STREAM_PIPES, 00102 * the return value will be the same as @arg len (this is 00103 * also possible if the message is exactly the same length 00104 * as @arg len, and the two cases are indistinguishable). 00105 * Without @c ACE_HAS_STREAM_PIPES, the return value is 00106 * the total length of the message, including bytes in 00107 * excess of @arg len. The excess bytes are discarded. 00108 */ 00109 ssize_t recv (void *buf, size_t len); 00110 00111 #if defined (ACE_HAS_STREAM_PIPES) 00112 /// Recv <data> and <cntl> message via Stream pipes. 00113 ssize_t recv (ACE_Str_Buf *data, 00114 ACE_Str_Buf *cntl, 00115 int *flags); 00116 00117 /// Recv <data> and <cntl> message via Stream pipes in "band" mode. 00118 ssize_t recv (int *band, 00119 ACE_Str_Buf *data, 00120 ACE_Str_Buf *cntl, 00121 int *flags); 00122 #endif /* ACE_HAS_STREAM_PIPES */ 00123 00124 /// Dump the state of an object. 00125 void dump (void) const; 00126 00127 /// Declare the dynamic allocation hooks. 00128 ACE_ALLOC_HOOK_DECLARE; 00129 }; 00130 00131 ACE_END_VERSIONED_NAMESPACE_DECL 00132 00133 #if defined (__ACE_INLINE__) 00134 #include "ace/FIFO_Recv_Msg.inl" 00135 #endif /* __ACE_INLINE__ */ 00136 00137 #include /**/ "ace/post.h" 00138 #endif /* ACE_FIFO_RECV_MSG_H */