Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / Pipe.h
blob1034b4e117c8fdf90d8fe54db51886bd985f6d76
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Pipe.h
7 * $Id: Pipe.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
11 //==========================================================================
13 #ifndef ACE_PIPE_H
14 #define ACE_PIPE_H
16 #include /**/ "ace/pre.h"
18 #include /**/ "ace/ACE_export.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/Default_Constants.h"
26 #include "ace/OS_NS_sys_uio.h"
27 #include "ace/OS_NS_unistd.h"
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 // Forward decl.
32 class ACE_Message_Block;
33 class ACE_Time_Value;
35 /**
36 * @class ACE_Pipe
38 * @brief Provides a portable bidirectional "pipe" abstraction.
40 * This class is designed to work with select()-based demuxers, such
41 * as the ACE_Select_Reactor, which is why it uses sockets on Windows
42 * rather than Win32 pipes (which aren't select()'able).
44 class ACE_Export ACE_Pipe
46 public:
47 // = Initialization and termination.
48 /// Default constructor (does nothing...).
49 ACE_Pipe (void);
51 /// Open the pipe and initialize the handles.
52 ACE_Pipe (ACE_HANDLE handles[2]);
54 /// Initialize the ACE_Pipe from the @a read and @a write handles.
55 ACE_Pipe (ACE_HANDLE read, ACE_HANDLE write);
57 /// Default dtor. It doesn't close the handles for you.
58 ~ACE_Pipe (void);
60 /// Open the pipe and initialize the handles.
61 int open (ACE_HANDLE handles[2]);
63 /// Open the pipe, setting the buffer size to the maximum.
64 int open (int buffer_size = ACE_DEFAULT_MAX_SOCKET_BUFSIZ);
66 /// Close down the pipe HANDLEs;
67 int close (void);
69 // = Accessors.
71 /**
72 * This is the "read" side of the pipe. Note, however, that
73 * processes can also write to this handle as well since pipes are
74 * bi-directional.
76 ACE_HANDLE read_handle (void) const;
78 /**
79 * This is the "write" side of the pipe. Note, however, that
80 * processes can also read to this handle as well since pipes are
81 * bi-directional.
83 ACE_HANDLE write_handle (void) const;
85 /// Dump the state of the object.
86 void dump (void) const;
88 /// send upto @a n bytes in @a buf.
89 ssize_t send (const void *buf, size_t n) const;
91 /// Recv upto @a n bytes in @a buf.
92 ssize_t recv (void *buf, size_t n) const;
94 /// Send n bytes, keep trying until n are sent.
95 ssize_t send_n (const void *buf, size_t n) const;
97 /// Send all the @a message_blocks chained through their <next> and
98 /// <cont> pointers. This call uses the underlying OS gather-write
99 /// operation to reduce the domain-crossing penalty.
100 ssize_t send_n (const ACE_Message_Block *message_block,
101 const ACE_Time_Value *timeout = 0,
102 size_t *bytes_transferred = 0);
104 /// Recv n bytes, keep trying until n are received.
105 ssize_t recv_n (void *buf, size_t n) const;
107 /// Send iovecs via <::writev>.
108 ssize_t send (const iovec iov[], int n) const;
110 /// Recv iovecs via <::readv>.
111 ssize_t recv (iovec iov[], int n) const;
114 * Send N char *ptrs and int lengths. Note that the char *'s
115 * precede the ints (basically, an varargs version of writev). The
116 * count N is the *total* number of trailing arguments, *not* a
117 * couple of the number of tuple pairs!
119 ssize_t send (size_t n, ...) const;
122 * This is an interface to ::readv, that doesn't use the struct
123 * iovec explicitly. The ... can be passed as an arbitrary number
124 * of (char *ptr, int len) tuples. However, the count N is the
125 * *total* number of trailing arguments, *not* a couple of the
126 * number of tuple pairs!
128 ssize_t recv (size_t n, ...) const;
130 /// Send @a n bytes via Win32 WriteFile using overlapped I/O.
131 ssize_t send (const void *buf,
132 size_t n,
133 ACE_OVERLAPPED *overlapped) const;
135 /// Recv @a n bytes via Win32 ReadFile using overlapped I/O.
136 ssize_t recv (void *buf,
137 size_t n,
138 ACE_OVERLAPPED *overlapped) const;
140 /// Send an <iovec> of size @a n to the file.
141 ssize_t sendv (const iovec iov[],
142 int n) const;
144 /// Send an @c iovec of size @a n to the file. Will block until all
145 /// bytes are sent or an error occurs.
146 ssize_t sendv_n (const iovec iov[],
147 int n) const;
149 /// Receive an @c iovec of size @a n to the file.
150 ssize_t recvv_n (iovec iov[],
151 int n) const;
153 private:
154 ACE_HANDLE handles_[2];
157 ACE_END_VERSIONED_NAMESPACE_DECL
159 #if defined (__ACE_INLINE__)
160 #include "ace/Pipe.inl"
161 #endif /* __ACE_INLINE__ */
163 #include /**/ "ace/post.h"
165 #endif /* ACE_PIPE_H */