Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

FIFO_Recv_Msg.h

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

Generated on Mon Jun 16 11:19:39 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002