Restore build on FreeBSD.
[getmangos.git] / dep / ACE_wrappers / ace / DEV_IO.h
blob3b1c3deb33405467da20f11f5e6775b9a748d9a8
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file DEV_IO.h
7 * $Id: DEV_IO.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Gerhard Lenzer
10 * @author Douglas C. Schmidt
12 //=============================================================================
14 #ifndef ACE_DEV_IO_H
15 #define ACE_DEV_IO_H
16 #include /**/ "ace/pre.h"
18 #include "ace/DEV.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #if defined (ACE_HAS_STREAM_PIPES)
25 # include "ace/OS_NS_stropts.h"
26 #endif /* ACE_HAS_STREAM_PIPES */
28 #include "ace/os_include/os_stdio.h"
29 #include "ace/os_include/sys/os_uio.h"
31 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
33 class ACE_Time_Value;
35 /**
36 * @class ACE_DEV_IO
38 * @brief Read/Write operations on Devices.
40 class ACE_Export ACE_DEV_IO : public ACE_DEV
42 public:
43 friend class ACE_DEV_Connector;
45 /// Default constructor.
46 ACE_DEV_IO (void);
48 // = Various send operations.
49 /// send upto @a n bytes in @a buf.
50 ssize_t send (const void *buf, size_t n) const;
52 /// Recv upto @a n bytes in @a buf.
53 ssize_t recv (void *buf, size_t n) const;
55 /// Send n bytes, keep trying until n are sent.
56 ssize_t send_n (const void *buf,
57 size_t n) const;
59 /**
60 * @name I/O operations
62 * Notes on common parameters:
64 * @a buf is the buffer to write from or receive into.
66 * @a len is the number of bytes to transfer.
68 * The @a timeout parameter in the following methods indicates how
69 * long to blocking trying to transfer data. If @a timeout == 0,
70 * then the call behaves as a normal send/recv call, i.e., for
71 * blocking sockets, the call will block until action is possible;
72 * for non-blocking sockets, EWOULDBLOCK will be returned if no
73 * action is immediately possible.
75 * If @a timeout != 0, the call will wait until the relative time
76 * specified in *@a timeout elapses.
78 * The "_n()" I/O methods keep looping until all the data has been
79 * transferred. These methods also work for sockets in non-blocking
80 * mode i.e., they keep looping on EWOULDBLOCK. @a timeout is used
81 * to make sure we keep making progress, i.e., the same timeout
82 * value is used for every I/O operation in the loop and the timeout
83 * is not counted down.
85 * The return values for the "*_n()" methods match the return values
86 * from the non "_n()" methods and are specified as follows:
88 * - On complete transfer, the number of bytes transferred is returned.
89 * - On timeout, -1 is returned, errno == ETIME.
90 * - On error, -1 is returned, errno is set to appropriate error.
91 * - On EOF, 0 is returned, errno is irrelevant.
93 * On partial transfers, i.e., if any data is transferred before
94 * timeout/error/EOF, @a bytes_transferred will contain the number of
95 * bytes transferred.
97 ssize_t recv_n (void *buf,
98 size_t n,
99 const ACE_Time_Value *timeout = 0,
100 size_t *bytes_transferred = 0) const;
102 #if defined (ACE_HAS_STREAM_PIPES)
103 /// Recv bytes via STREAM pipes using "band" mode.
104 ssize_t recv (ACE_Str_Buf *cntl,
105 ACE_Str_Buf *data,
106 int *band,
107 int *flags) const;
109 /// Send bytes via STREAM pipes using "band" mode.
110 ssize_t send (const ACE_Str_Buf *cntl,
111 const ACE_Str_Buf *data,
112 int band,
113 int flags) const;
115 /// Recv @a cntl and @a data via STREAM pipes.
116 ssize_t recv (ACE_Str_Buf *cntl,
117 ACE_Str_Buf *data,
118 int *flags) const;
120 /// Send @a cntl and @a data via STREAM pipes.
121 ssize_t send (const ACE_Str_Buf *cntl,
122 const ACE_Str_Buf *data,
123 int flags = 0) const;
124 #endif /* ACE_HAS_STREAM_PIPES */
126 /// Send iovecs via <::writev>.
127 ssize_t send (const iovec iov[], size_t n) const;
129 /// Recv iovecs via <::readv>.
130 ssize_t recv (iovec iov[], size_t n) const;
133 * Send N char *ptrs and int lengths. Note that the char *'s
134 * precede the ints (basically, an varargs version of writev). The
135 * count N is the *total* number of trailing arguments, *not* a
136 * couple of the number of tuple pairs!
138 ssize_t send (size_t n, ...) const;
141 * This is an interface to ::readv, that doesn't use the struct
142 * iovec explicitly. The ... can be passed as an arbitrary number
143 * of (char *ptr, int len) tuples. However, the count N is the
144 * *total* number of trailing arguments, *not* a couple of the
145 * number of tuple pairs!
147 ssize_t recv (size_t n, ...) const;
149 /// Send @a n bytes via Win32 WriteFile using overlapped I/O.
150 ssize_t send (const void *buf, size_t n, ACE_OVERLAPPED *overlapped) const;
152 /// Recv @a n bytes via Win32 ReadFile using overlapped I/O.
153 ssize_t recv (void *buf, size_t n, ACE_OVERLAPPED *overlapped) const;
155 /// Dump the state of an object.
156 void dump (void) const;
158 // = The following two methods are no-ops to keep the
159 // ACE_Connector happy.
160 /// Return the local endpoint address.
161 int get_local_addr (ACE_DEV_Addr &) const;
163 /// Return the address of the remotely connected peer (if there is
164 /// one).
165 int get_remote_addr (ACE_DEV_Addr &) const;
167 /// Declare the dynamic allocation hooks.
168 ACE_ALLOC_HOOK_DECLARE;
170 // = Meta-type info
171 typedef ACE_DEV_Addr PEER_ADDR;
173 private:
174 /// Address of device we are connected to.
175 ACE_DEV_Addr addr_;
178 ACE_END_VERSIONED_NAMESPACE_DECL
180 #if defined (__ACE_INLINE__)
181 #include "ace/DEV_IO.inl"
182 #endif /* __ACE_INLINE__ */
184 #include /**/ "ace/post.h"
185 #endif /* ACE_DEV_IO_H */