3 //=============================================================================
5 * @file WIN32_Asynch_IO.h
7 * $Id: WIN32_Asynch_IO.h 80826 2008-03-04 14:51:23Z wotte $
10 * These classes only works on Win32 platforms.
12 * The implementation of ACE_Asynch_Transmit_File,
13 * ACE_Asynch_Accept, and ACE_Asynch_Connect are only supported if
14 * ACE_HAS_WINSOCK2 is defined or you are on WinNT 4.0 or higher.
17 * @author Irfan Pyarali <irfan@cs.wustl.edu>
18 * @author Tim Harrison <harrison@cs.wustl.edu>
19 * @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
20 * @author Roger Tragin <r.tragin@computer.org>
21 * @author Alexander Libman <alibman@ihug.com.au>
23 //=============================================================================
25 #ifndef ACE_WIN32_ASYNCH_IO_H
26 #define ACE_WIN32_ASYNCH_IO_H
27 #include /**/ "ace/pre.h"
29 #include /**/ "ace/config-all.h"
31 #if !defined (ACE_LACKS_PRAGMA_ONCE)
33 #endif /* ACE_LACKS_PRAGMA_ONCE */
35 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) && \
36 (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 == 1))
38 #include "ace/Asynch_IO_Impl.h"
40 #include "ace/Event_Handler.h"
41 #include "ace/Handle_Set.h"
42 #include "ace/Map_Manager.h"
43 #include "ace/Null_Mutex.h"
45 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
47 // Forward declaration
48 class ACE_WIN32_Proactor
;
51 * @class ACE_WIN32_Asynch_Result
53 * @brief An abstract class which adds information to the OVERLAPPED
54 * structure to make it more useful.
56 * An abstract base class from which you can obtain some basic
57 * information like the number of bytes transferred, the ACT
58 * associated with the asynchronous operation, indication of
59 * success or failure, etc. Subclasses may want to store more
60 * information that is particular to the asynchronous operation
63 class ACE_Export ACE_WIN32_Asynch_Result
: public virtual ACE_Asynch_Result_Impl
,
66 /// Factory class has special permissions.
67 friend class ACE_WIN32_Asynch_Accept
;
69 /// Proactor class has special permission.
70 friend class ACE_WIN32_Proactor
;
73 /// Number of bytes transferred by the operation.
74 size_t bytes_transferred (void) const;
76 /// ACT associated with the operation.
77 const void *act (void) const;
79 /// Did the operation succeed?
80 int success (void) const;
83 * This returns the ACT associated with the handle when it was
84 * registered with the I/O completion port. This ACT is not the
85 * same as the ACT associated with the asynchronous operation.
87 const void *completion_key (void) const;
89 /// Error value if the operation fail.
90 u_long
error (void) const;
92 /// Event associated with the OVERLAPPED structure.
93 ACE_HANDLE
event (void) const;
95 /// This really make sense only when doing file I/O.
96 u_long
offset (void) const;
98 /// Offset_high associated with the OVERLAPPED structure.
99 u_long
offset_high (void) const;
101 /// The priority of the asynchronous operation. Currently, this is
102 /// not supported on Win32.
103 int priority (void) const;
106 int signal_number (void) const;
108 /// Post @c this to the Proactor's completion port.
109 int post_completion (ACE_Proactor_Impl
*proactor
);
112 virtual ~ACE_WIN32_Asynch_Result (void);
114 /// Simulate error value to use in the post_completion ()
115 void set_error (u_long errcode
);
117 /// Simulate value to use in the post_completion ()
118 void set_bytes_transferred (size_t nbytes
);
122 ACE_WIN32_Asynch_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
128 int signal_number
= 0);
130 /// Proxy for the ACE_Handler that will be called back.
131 ACE_Handler::Proxy_Ptr handler_proxy_
;
133 /// ACT for this operation.
136 /// Bytes transferred by this operation.
137 size_t bytes_transferred_
;
139 /// Success indicator.
142 /// ACT associated with handle.
143 const void *completion_key_
;
145 /// Error if operation failed.
150 * @class ACE_WIN32_Asynch_Operation
152 * @brief This class abstracts out the common things needed for
153 * implementing Asynch_Operation for WIN32 platform.
156 class ACE_Export ACE_WIN32_Asynch_Operation
: public virtual ACE_Asynch_Operation_Impl
160 * Initializes the factory with information which will be used with
161 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
162 * <ACE_Handler::handle> will be called on the @a handler to get the
165 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
167 const void *completion_key
,
168 ACE_Proactor
*proactor
);
171 * This cancels all pending accepts operations that were issued by
172 * the calling thread. The function does not cancel asynchronous
173 * operations issued by other threads.
179 /// Return the underlying proactor.
180 ACE_Proactor
* proactor (void) const;
184 ACE_WIN32_Asynch_Operation (ACE_WIN32_Proactor
*win32_proactor
);
187 virtual ~ACE_WIN32_Asynch_Operation (void);
190 ACE_WIN32_Proactor
*win32_proactor_
;
192 /// Proactor that this asynch IO is registered with.
193 ACE_Proactor
*proactor_
;
195 /// Handler that will receive the callback.
196 ACE_Handler::Proxy_Ptr handler_proxy_
;
198 /// I/O handle used for reading.
203 * @class ACE_WIN32_Asynch_Read_Stream_Result
205 * @brief This class provides concrete implementation for
206 * ACE_Asynch_Read_Stream::Result class.
208 class ACE_Export ACE_WIN32_Asynch_Read_Stream_Result
: public virtual ACE_Asynch_Read_Stream_Result_Impl
,
209 public ACE_WIN32_Asynch_Result
211 /// Factory class will have special permissions.
212 friend class ACE_WIN32_Asynch_Read_Stream
;
214 /// Proactor class has special permission.
215 friend class ACE_WIN32_Proactor
;
218 /// The number of bytes which were requested at the start of the
219 /// asynchronous read.
220 size_t bytes_to_read (void) const;
222 /// Message block which contains the read data.
223 ACE_Message_Block
&message_block (void) const;
225 /// I/O handle used for reading.
226 ACE_HANDLE
handle (void) const;
228 // Base class operations. These operations are here to kill
229 // dominance warnings. These methods call the base class methods.
231 /// Number of bytes transferred by the operation.
232 size_t bytes_transferred (void) const;
234 /// ACT associated with the operation.
235 const void *act (void) const;
237 /// Did the operation succeed?
238 int success (void) const;
241 * This returns the ACT associated with the handle when it was
242 * registered with the I/O completion port. This ACT is not the
243 * same as the ACT associated with the asynchronous operation.
245 const void *completion_key (void) const;
247 /// Error value if the operation fail.
248 u_long
error (void) const;
250 /// Event associated with the OVERLAPPED structure.
251 ACE_HANDLE
event (void) const;
253 /// This really make sense only when doing file I/O.
254 u_long
offset (void) const;
256 /// Offset_high associated with the OVERLAPPED structure.
257 u_long
offset_high (void) const;
259 /// The priority of the asynchronous operation. Currently, this is
260 /// not supported on Win32.
261 int priority (void) const;
263 /// No-op. Returns 0.
264 int signal_number (void) const;
266 /// Post @c this to the Proactor's completion port.
267 int post_completion (ACE_Proactor_Impl
*proactor
);
269 /// Accessor for the scatter read flag
270 int scatter_enabled (void) const;
273 /// Constructor is protected since creation is limited to
274 /// ACE_Asynch_Read_Stream factory.
275 ACE_WIN32_Asynch_Read_Stream_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
277 ACE_Message_Block
&message_block
,
278 size_t bytes_to_read
,
282 int signal_number
= 0,
283 int scatter_enabled
= 0);
285 /// Proactor will call this method when the read completes.
286 virtual void complete (size_t bytes_transferred
,
288 const void *completion_key
,
292 virtual ~ACE_WIN32_Asynch_Read_Stream_Result (void);
294 /// Bytes requested when the asynchronous read was initiated.
295 size_t bytes_to_read_
;
297 /// Message block for reading the data into.
298 ACE_Message_Block
&message_block_
;
300 /// I/O handle used for reading.
303 /// Flag for scatter read
304 int scatter_enabled_
;
308 * @class ACE_WIN32_Asynch_Read_Stream
310 * @brief This class is a factory for starting off asynchronous reads
313 * Once <open> is called, multiple asynchronous <read>s can
314 * started using this class. An ACE_Asynch_Read_Stream::Result
315 * will be passed back to the @a handler when the asynchronous
316 * reads completes through the <ACE_Handler::handle_read_stream>
319 class ACE_Export ACE_WIN32_Asynch_Read_Stream
: public virtual ACE_Asynch_Read_Stream_Impl
,
320 public ACE_WIN32_Asynch_Operation
325 ACE_WIN32_Asynch_Read_Stream (ACE_WIN32_Proactor
*win32_proactor
);
327 /// This starts off an asynchronous read. Upto @a bytes_to_read will
328 /// be read and stored in the @a message_block.
329 int read (ACE_Message_Block
&message_block
,
330 size_t bytes_to_read
,
333 int signal_number
= 0);
336 * Same as above but with scatter support, through chaining of composite
337 * message blocks using the continuation field.
339 int readv (ACE_Message_Block
&message_block
,
340 size_t bytes_to_read
,
343 int signal_number
= 0);
346 virtual ~ACE_WIN32_Asynch_Read_Stream (void);
348 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
349 // methods are defined here to avoid VC++ warnings. They route the
350 // call to the ACE_WIN32_Asynch_Operation base class.
353 * Initializes the factory with information which will be used with
354 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
355 * <ACE_Handler::handle> will be called on the @a handler to get the
358 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
360 const void *completion_key
,
361 ACE_Proactor
*proactor
);
364 * This cancels all pending accepts operations that were issued by
365 * the calling thread. The function does not cancel asynchronous
366 * operations issued by other threads.
370 /// Return the underlying proactor.
371 ACE_Proactor
* proactor (void) const;
374 /// This is the method which does the real work and is there so that
375 /// the ACE_Asynch_Read_File class can use it too.
376 int shared_read (ACE_WIN32_Asynch_Read_Stream_Result
*result
);
380 * @class ACE_WIN32_Asynch_Write_Stream_Result
382 * @brief This class provides concrete implementation for
383 * ACE_Asynch_Write_Stream::Result class.
385 class ACE_Export ACE_WIN32_Asynch_Write_Stream_Result
: public virtual ACE_Asynch_Write_Stream_Result_Impl
,
386 public ACE_WIN32_Asynch_Result
388 /// Factory class willl have special permissions.
389 friend class ACE_WIN32_Asynch_Write_Stream
;
391 /// Proactor class has special permission.
392 friend class ACE_WIN32_Proactor
;
395 /// The number of bytes which were requested at the start of the
396 /// asynchronous write.
397 size_t bytes_to_write (void) const;
399 /// Message block that contains the data to be written.
400 ACE_Message_Block
&message_block (void) const;
402 /// I/O handle used for writing.
403 ACE_HANDLE
handle (void) const;
405 // = Base class operations. These operations are here to kill some
406 // warnings. These methods call the base class methods.
408 /// Number of bytes transferred by the operation.
409 size_t bytes_transferred (void) const;
411 /// ACT associated with the operation.
412 const void *act (void) const;
414 /// Did the operation succeed?
415 int success (void) const;
418 * This returns the ACT associated with the handle when it was
419 * registered with the I/O completion port. This ACT is not the
420 * same as the ACT associated with the asynchronous operation.
422 const void *completion_key (void) const;
424 /// Error value if the operation fail.
425 u_long
error (void) const;
427 /// Event associated with the OVERLAPPED structure.
428 ACE_HANDLE
event (void) const;
430 /// This really make sense only when doing file I/O.
431 u_long
offset (void) const;
433 /// Offset_high associated with the OVERLAPPED structure.
434 u_long
offset_high (void) const;
436 /// The priority of the asynchronous operation. Currently, this is
437 /// not supported on Win32.
438 int priority (void) const;
440 /// No-op. Returns 0.
441 int signal_number (void) const;
443 /// Post @c this to the Proactor's completion port.
444 int post_completion (ACE_Proactor_Impl
*proactor
);
446 /// Accessor for the gather write flag
447 int gather_enabled (void) const;
450 /// Constructor is protected since creation is limited to
451 /// ACE_Asynch_Write_Stream factory.
452 ACE_WIN32_Asynch_Write_Stream_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
454 ACE_Message_Block
&message_block
,
455 size_t bytes_to_write
,
459 int signal_number
= 0,
460 int gather_enabled
= 0);
462 /// ACE_Proactor will call this method when the write completes.
463 virtual void complete (size_t bytes_transferred
,
465 const void *completion_key
,
469 virtual ~ACE_WIN32_Asynch_Write_Stream_Result (void);
471 /// The number of bytes which were requested at the start of the
472 /// asynchronous write.
473 size_t bytes_to_write_
;
475 /// Message block that contains the data to be written.
476 ACE_Message_Block
&message_block_
;
478 /// I/O handle used for writing.
481 /// Flag for gather write
486 * @class ACE_WIN32_Asynch_Write_Stream
488 * @brief This class is a factory for starting off asynchronous writes
492 * Once <open> is called, multiple asynchronous <writes>s can
493 * started using this class. A ACE_Asynch_Write_Stream::Result
494 * will be passed back to the @a handler when the asynchronous
495 * write completes through the
496 * <ACE_Handler::handle_write_stream> callback.
498 class ACE_Export ACE_WIN32_Asynch_Write_Stream
: public virtual ACE_Asynch_Write_Stream_Impl
,
499 public ACE_WIN32_Asynch_Operation
503 ACE_WIN32_Asynch_Write_Stream (ACE_WIN32_Proactor
*win32_proactor
);
505 /// This starts off an asynchronous write. Upto @a bytes_to_write
506 /// will be written from the @a message_block.
507 int write (ACE_Message_Block
&message_block
,
508 size_t bytes_to_write
,
511 int signal_number
= 0);
514 * Same as above but with gather support, through chaining of composite
515 * message blocks using the continuation field.
517 int writev (ACE_Message_Block
&message_block
,
518 size_t bytes_to_write
,
521 int signal_number
= 0);
524 virtual ~ACE_WIN32_Asynch_Write_Stream (void);
526 // = Methods belonging to <ACE_WIN32_Asynch_Operation> base class.
528 // These methods are defined here to avoid VC++ warnings. They route
529 // the call to the <ACE_WIN32_Asynch_Operation> base class.
532 * Initializes the factory with information which will be used with
533 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
534 * <ACE_Handler::handle> will be called on the @a handler to get the
537 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
539 const void *completion_key
,
540 ACE_Proactor
*proactor
);
543 * This cancels all pending accepts operations that were issued by
544 * the calling thread. The function does not cancel asynchronous
545 * operations issued by other threads.
549 /// Return the underlying proactor.
550 ACE_Proactor
* proactor (void) const;
553 /// This is the method which does the real work and is there so that
554 /// the ACE_Asynch_Write_File class can use it too.
555 int shared_write (ACE_WIN32_Asynch_Write_Stream_Result
*result
);
559 * @class ACE_WIN32_Asynch_Read_File_Result
561 * @brief This class provides concrete implementation for
562 * ACE_Asynch_Read_File::Result class.
564 class ACE_Export ACE_WIN32_Asynch_Read_File_Result
: public virtual ACE_Asynch_Read_File_Result_Impl
,
565 public ACE_WIN32_Asynch_Read_Stream_Result
567 /// Factory class will have special permissions.
568 friend class ACE_WIN32_Asynch_Read_File
;
570 /// Proactor class has special permission.
571 friend class ACE_WIN32_Proactor
;
574 // = These methods belong to ACE_WIN32_Asynch_Result class base
575 // class. These operations are here to kill some warnings. These
576 // methods call the base class methods.
578 /// Number of bytes transferred by the operation.
579 size_t bytes_transferred (void) const;
581 /// ACT associated with the operation.
582 const void *act (void) const;
584 /// Did the operation succeed?
585 int success (void) const;
588 * This returns the ACT associated with the handle when it was
589 * registered with the I/O completion port. This ACT is not the
590 * same as the ACT associated with the asynchronous operation.
592 const void *completion_key (void) const;
594 /// Error value if the operation fail.
595 u_long
error (void) const;
597 /// Event associated with the OVERLAPPED structure.
598 ACE_HANDLE
event (void) const;
600 /// This really make sense only when doing file I/O.
601 u_long
offset (void) const;
603 /// Offset_high associated with the OVERLAPPED structure.
604 u_long
offset_high (void) const;
606 /// The priority of the asynchronous operation. Currently, this is
607 /// not supported on Win32.
608 int priority (void) const;
610 /// No-op. Returns 0.
611 int signal_number (void) const;
613 // The following methods belong to
614 // ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++
615 // dominance warnings. These methods route their call to the
616 // ACE_WIN32_Asynch_Read_Stream_Result base class.
618 /// The number of bytes which were requested at the start of the
619 /// asynchronous read.
620 size_t bytes_to_read (void) const;
622 /// Message block which contains the read data.
623 ACE_Message_Block
&message_block (void) const;
625 /// I/O handle used for reading.
626 ACE_HANDLE
handle (void) const;
628 /// Post @c this to the Proactor's completion port.
629 int post_completion (ACE_Proactor_Impl
*proactor
);
632 /// Constructor is protected since creation is limited to
633 /// ACE_Asynch_Read_File factory.
634 ACE_WIN32_Asynch_Read_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
636 ACE_Message_Block
&message_block
,
637 size_t bytes_to_read
,
643 int signal_number
= 0,
644 int scatter_enabled
= 0);
646 /// ACE_Proactor will call this method when the read completes.
647 virtual void complete (size_t bytes_transferred
,
649 const void *completion_key
,
653 virtual ~ACE_WIN32_Asynch_Read_File_Result (void);
657 * @class ACE_WIN32_Asynch_Read_File
659 * @brief This class is a factory for starting off asynchronous reads
662 * Once <open> is called, multiple asynchronous <read>s can
663 * started using this class. A ACE_Asynch_Read_File::Result
664 * will be passed back to the @a handler when the asynchronous
665 * reads completes through the <ACE_Handler::handle_read_file>
668 * This class differs slightly from ACE_Asynch_Read_Stream as it
669 * allows the user to specify an offset for the read.
671 class ACE_Export ACE_WIN32_Asynch_Read_File
: public virtual ACE_Asynch_Read_File_Impl
,
672 public ACE_WIN32_Asynch_Read_Stream
677 ACE_WIN32_Asynch_Read_File (ACE_WIN32_Proactor
*win32_proactor
);
680 * This starts off an asynchronous read. Upto @a bytes_to_read will
681 * be read and stored in the @a message_block. The read will start
682 * at @a offset from the beginning of the file.
684 int read (ACE_Message_Block
&message_block
,
685 size_t bytes_to_read
,
690 int signal_number
= 0);
693 * Same as above but with scatter support, through chaining of
694 * composite message blocks using the continuation field.
695 * @note Each data block payload must be at least the size of a
696 * system memory page and must be aligned on a system memory page
699 int readv (ACE_Message_Block
&message_block
,
700 size_t bytes_to_read
,
705 int signal_number
= 0);
709 virtual ~ACE_WIN32_Asynch_Read_File (void);
711 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
712 // methods are defined here to avoid VC++ warnings. They route the
713 // call to the ACE_WIN32_Asynch_Operation base class.
716 * Initializes the factory with information which will be used with
717 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
718 * <ACE_Handler::handle> will be called on the @a handler to get the
721 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
723 const void *completion_key
,
724 ACE_Proactor
*proactor
);
727 * This cancels all pending accepts operations that were issued by
728 * the calling thread. The function does not cancel asynchronous
729 * operations issued by other threads.
733 /// Return the underlying proactor.
734 ACE_Proactor
* proactor (void) const;
738 * This method belongs to ACE_WIN32_Asynch_Read_Stream. It is here
739 * to avoid the compiler warnings. We forward this call to the
740 * ACE_WIN32_Asynch_Read_Stream class.
742 int read (ACE_Message_Block
&message_block
,
743 size_t bytes_to_read
,
746 int signal_number
= 0);
749 * Same as above but with scatter support, through chaining of composite
750 * message blocks using the continuation field.
752 int readv (ACE_Message_Block
&message_block
,
753 size_t bytes_to_read
,
756 int signal_number
= 0);
760 * @class ACE_WIN32_Asynch_Write_File_Result
762 * @brief This class provides implementation for
763 * ACE_Asynch_Write_File_Result for WIN32 platforms.
765 * This class has all the information necessary for the
766 * @a handler to uniquiely identify the completion of the
767 * asynchronous write.
769 * This class differs slightly from
770 * ACE_Asynch_Write_Stream::Result as it calls back
771 * <ACE_Handler::handle_write_file> on the @a handler instead
772 * of <ACE_Handler::handle_write_stream>. No additional state
773 * is required by this class as ACE_Asynch_Result can store
776 class ACE_Export ACE_WIN32_Asynch_Write_File_Result
: public virtual ACE_Asynch_Write_File_Result_Impl
,
777 public ACE_WIN32_Asynch_Write_Stream_Result
779 /// Factory class will have special permission.
780 friend class ACE_WIN32_Asynch_Write_File
;
782 /// Proactor class has special permission.
783 friend class ACE_WIN32_Proactor
;
786 // = Base class operations. These operations are here to kill some
787 // warnings. These methods call the base class methods.
789 /// Number of bytes transferred by the operation.
790 size_t bytes_transferred (void) const;
792 /// ACT associated with the operation.
793 const void *act (void) const;
795 /// Did the operation succeed?
796 int success (void) const;
799 * This returns the ACT associated with the handle when it was
800 * registered with the I/O completion port. This ACT is not the
801 * same as the ACT associated with the asynchronous operation.
803 const void *completion_key (void) const;
805 /// Error value if the operation fail.
806 u_long
error (void) const;
808 /// Event associated with the OVERLAPPED structure.
809 ACE_HANDLE
event (void) const;
811 /// This really make sense only when doing file I/O.
812 u_long
offset (void) const;
814 /// Offset_high associated with the OVERLAPPED structure.
815 u_long
offset_high (void) const;
817 /// The priority of the asynchronous operation. Currently, this is
818 /// not supported on Win32.
819 int priority (void) const;
821 /// No-op. Returns 0.
822 int signal_number (void) const;
824 // The following methods belong to
825 // ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++
826 // warnings. These methods route their call to the
827 // ACE_WIN32_Asynch_Read_Stream_Result base class.
829 /// The number of bytes which were requested at the start of the
830 /// asynchronous write.
831 size_t bytes_to_write (void) const;
833 /// Message block that contains the data to be written.
834 ACE_Message_Block
&message_block (void) const;
836 /// I/O handle used for writing.
837 ACE_HANDLE
handle (void) const;
839 /// Post @c this to the Proactor's completion port.
840 int post_completion (ACE_Proactor_Impl
*proactor
);
843 /// Constructor is protected since creation is limited to
844 /// ACE_Asynch_Write_File factory.
845 ACE_WIN32_Asynch_Write_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
847 ACE_Message_Block
&message_block
,
848 size_t bytes_to_write
,
854 int signal_number
= 0,
855 int gather_enabled
= 0);
857 /// ACE_Proactor will call this method when the write completes.
858 virtual void complete (size_t bytes_transferred
,
860 const void *completion_key
,
864 virtual ~ACE_WIN32_Asynch_Write_File_Result (void);
868 * @class ACE_WIN32_Asynch_Write_File
870 * @brief This class is a factory for starting off asynchronous writes
873 * Once <open> is called, multiple asynchronous <write>s can be
874 * started using this class. A ACE_Asynch_Write_File::Result
875 * will be passed back to the @a handler when the asynchronous
876 * writes completes through the <ACE_Handler::handle_write_file>
879 class ACE_Export ACE_WIN32_Asynch_Write_File
: public virtual ACE_Asynch_Write_File_Impl
,
880 public ACE_WIN32_Asynch_Write_Stream
884 ACE_WIN32_Asynch_Write_File (ACE_WIN32_Proactor
*win32_proactor
);
887 * This starts off an asynchronous write. Upto @a bytes_to_write
888 * will be write and stored in the @a message_block. The write will
889 * start at @a offset from the beginning of the file.
891 int write (ACE_Message_Block
&message_block
,
892 size_t bytes_to_write
,
897 int signal_number
= 0);
900 * Same as above but with gather support, through chaining of
901 * composite message blocks using the continuation field.
902 * @note Each data block payload must be at least the size of a
903 * system memory page and must be aligned on a system memory page
906 int writev (ACE_Message_Block
&message_block
,
907 size_t bytes_to_write
,
912 int signal_number
= 0);
915 virtual ~ACE_WIN32_Asynch_Write_File (void);
917 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
918 // methods are defined here to avoid VC++ warnings. They route the
919 // call to the ACE_WIN32_Asynch_Operation base class.
922 * Initializes the factory with information which will be used with
923 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
924 * <ACE_Handler::handle> will be called on the @a handler to get the
927 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
929 const void *completion_key
,
930 ACE_Proactor
*proactor
);
933 * This cancels all pending accepts operations that were issued by
934 * the calling thread. The function does not cancel asynchronous
935 * operations issued by other threads.
939 /// Return the underlying proactor.
940 ACE_Proactor
* proactor (void) const;
944 * This method belongs to ACE_WIN32_Asynch_Write_Stream. It is here
945 * to avoid compiler warnings. This method is forwarded to the
946 * ACE_WIN32_Asynch_Write_Stream class.
948 int write (ACE_Message_Block
&message_block
,
949 size_t bytes_to_write
,
952 int signal_number
= 0);
955 * Same as above but with gather support, through chaining of composite
956 * message blocks using the continuation field.
958 int writev (ACE_Message_Block
&message_block
,
959 size_t bytes_to_write
,
962 int signal_number
= 0);
966 * @class ACE_WIN32_Asynch_Accept_Result
968 * @brief This class implements ACE_Asynch_Accept::Result for WIN32
971 * This class has all the information necessary for the
972 * @a handler to uniquiely identify the completion of the
973 * asynchronous accept.
975 class ACE_Export ACE_WIN32_Asynch_Accept_Result
: public virtual ACE_Asynch_Accept_Result_Impl
,
976 public ACE_WIN32_Asynch_Result
978 /// Factory will have special permission.
979 friend class ACE_WIN32_Asynch_Accept
;
981 /// Proactor class has special permission.
982 friend class ACE_WIN32_Proactor
;
985 /// The number of bytes which were requested at the start of the
986 /// asynchronous accept.
987 size_t bytes_to_read (void) const;
989 /// Message block which contains the read data.
990 ACE_Message_Block
&message_block (void) const;
992 /// I/O handle used for accepting new connections.
993 ACE_HANDLE
listen_handle (void) const;
995 /// I/O handle for the new connection.
996 ACE_HANDLE
accept_handle (void) const;
998 // = Base class operations. These operations are here to kill some
999 // warnings. These methods call the base class methods.
1001 /// Number of bytes transferred by the operation.
1002 size_t bytes_transferred (void) const;
1004 /// ACT associated with the operation.
1005 const void *act (void) const;
1007 /// Did the operation succeed?
1008 int success (void) const;
1011 * This returns the ACT associated with the handle when it was
1012 * registered with the I/O completion port. This ACT is not the
1013 * same as the ACT associated with the asynchronous operation.
1015 const void *completion_key (void) const;
1017 /// Error value if the operation fail.
1018 u_long
error (void) const;
1020 /// Event associated with the OVERLAPPED structure.
1021 ACE_HANDLE
event (void) const;
1023 /// This really make sense only when doing file I/O.
1024 u_long
offset (void) const;
1026 /// Offset_high associated with the OVERLAPPED structure.
1027 u_long
offset_high (void) const;
1029 /// The priority of the asynchronous operation. Currently, this is
1030 /// not supported on Win32.
1031 int priority (void) const;
1033 /// No-op. Returns 0.
1034 int signal_number (void) const;
1036 /// Post @c this to the Proactor's completion port.
1037 int post_completion (ACE_Proactor_Impl
*proactor
);
1040 /// Constructor is protected since creation is limited to
1041 /// ACE_Asynch_Accept factory.
1042 ACE_WIN32_Asynch_Accept_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1043 ACE_HANDLE listen_handle
,
1044 ACE_HANDLE accept_handle
,
1045 ACE_Message_Block
&message_block
,
1046 size_t bytes_to_read
,
1050 int signal_number
= 0);
1052 /// ACE_Proactor will call this method when the accept completes.
1053 virtual void complete (size_t bytes_transferred
,
1055 const void *completion_key
,
1059 virtual ~ACE_WIN32_Asynch_Accept_Result (void);
1061 /// Bytes requested when the asynchronous read was initiated.
1062 size_t bytes_to_read_
;
1064 /// Message block for reading the data into.
1065 ACE_Message_Block
&message_block_
;
1067 /// I/O handle used for accepting new connections.
1068 ACE_HANDLE listen_handle_
;
1070 /// I/O handle for the new connection.
1071 ACE_HANDLE accept_handle_
;
1075 * @class ACE_WIN32_Asynch_Accept
1077 * @brief This class is a factory for starting off asynchronous accepts
1078 * on a listen handle.
1080 * Once <open> is called, multiple asynchronous <accept>s can
1081 * started using this class. A ACE_Asynch_Accept::Result will
1082 * be passed back to the @a handler when the asynchronous accept
1083 * completes through the <ACE_Handler::handle_accept>
1086 class ACE_Export ACE_WIN32_Asynch_Accept
: public virtual ACE_Asynch_Accept_Impl
,
1087 public ACE_WIN32_Asynch_Operation
1091 ACE_WIN32_Asynch_Accept (ACE_WIN32_Proactor
*win32_proactor
);
1094 * This starts off an asynchronous accept. The asynchronous accept
1095 * call also allows any initial data to be returned to the
1096 * @a handler. Upto @a bytes_to_read will be read and stored in the
1097 * @a message_block. The <accept_handle> will be used for the
1098 * <accept> call. If (<accept_handle> == INVALID_HANDLE), a new
1099 * handle will be created.
1101 * @a message_block must be specified. This is because the address of
1102 * the new connection is placed at the end of this buffer.
1104 int accept (ACE_Message_Block
&message_block
,
1105 size_t bytes_to_read
,
1106 ACE_HANDLE accept_handle
,
1109 int signal_number
= 0,
1110 int addr_family
= AF_INET
);
1113 ~ACE_WIN32_Asynch_Accept (void);
1115 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1116 // methods are defined here to avoid VC++ warnings. They route the
1117 // call to the ACE_WIN32_Asynch_Operation base class.
1120 * Initializes the factory with information which will be used with
1121 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1122 * <ACE_Handler::handle> will be called on the @a handler to get the
1125 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1127 const void *completion_key
,
1128 ACE_Proactor
*proactor
);
1131 * This cancels all pending accepts operations that were issued by
1132 * the calling thread. The function does not cancel asynchronous
1133 * operations issued by other threads.
1137 /// Return the underlying proactor.
1138 ACE_Proactor
* proactor (void) const;
1142 * @class ACE_WIN32_Asynch_Connect_Result
1144 * @brief This is that class which will be passed back to the
1145 * completion handler when the asynchronous connect completes.
1147 * This class has all the information necessary for the
1148 * completion handler to uniquiely identify the completion of the
1149 * asynchronous connect.
1151 class ACE_Export ACE_WIN32_Asynch_Connect_Result
: public virtual ACE_Asynch_Connect_Result_Impl
,
1152 public ACE_WIN32_Asynch_Result
1154 /// Factory classes will have special permissions.
1155 friend class ACE_WIN32_Asynch_Connect
;
1157 /// The Proactor constructs the Result class for faking results.
1158 friend class ACE_WIN32_Proactor
;
1162 /// I/O handle for the connection.
1163 ACE_HANDLE
connect_handle (void) const;
1165 // = Base class operations. These operations are here to kill some
1166 // warnings. These methods call the base class methods.
1168 /// Number of bytes transferred by the operation.
1169 size_t bytes_transferred (void) const;
1171 /// ACT associated with the operation.
1172 const void *act (void) const;
1174 /// Did the operation succeed?
1175 int success (void) const;
1178 * Returns the ACT associated with the handle when it was
1179 * registered with the I/O completion port. This ACT is not the
1180 * same as the ACT associated with the asynchronous operation.
1182 const void *completion_key (void) const;
1184 /// Error value if the operation fail.
1185 u_long
error (void) const;
1187 /// Event associated with the OVERLAPPED structure.
1188 ACE_HANDLE
event (void) const;
1190 /// This really make sense only when doing file I/O.
1191 u_long
offset (void) const;
1193 /// Offset_high associated with the OVERLAPPED structure.
1194 u_long
offset_high (void) const;
1196 /// The priority of the asynchronous operation. Currently, this is
1197 /// not supported on Win32.
1198 int priority (void) const;
1200 /// No-op. Returns 0.
1201 int signal_number (void) const;
1203 /// Post this object to the Proactor's completion port.
1204 int post_completion (ACE_Proactor_Impl
*proactor
);
1207 /// Constructor is protected since creation is limited to
1208 /// ACE_Asynch_Connect factory.
1209 ACE_WIN32_Asynch_Connect_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1210 ACE_HANDLE connect_handle
,
1216 /// ACE_Proactor will call this method when the accept completes.
1217 virtual void complete (size_t bytes_transferred
,
1219 const void *completion_key
,
1223 virtual ~ACE_WIN32_Asynch_Connect_Result (void);
1225 /// Set the I/O handle for the new connection.
1226 void connect_handle (ACE_HANDLE handle
);
1228 ACE_HANDLE connect_handle_
;
1233 * @class ACE_WIN32_Asynch_Connect
1235 class ACE_Export ACE_WIN32_Asynch_Connect
:
1236 public virtual ACE_Asynch_Connect_Impl
,
1237 public ACE_WIN32_Asynch_Operation
,
1238 public ACE_Event_Handler
1243 ACE_WIN32_Asynch_Connect (ACE_WIN32_Proactor
* win32_proactor
);
1246 virtual ~ACE_WIN32_Asynch_Connect (void);
1249 * This open belongs to ACE_WIN32_Asynch_Operation. We forward
1250 * this call to that method. We have put this here to avoid the
1251 * compiler warnings.
1253 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1255 const void *completion_key
,
1256 ACE_Proactor
*proactor
= 0);
1259 * Start an asynchronous connect.
1261 * @param connect_handle Handle to use for the connect. If the value
1262 * ACE_INVALID_HANDLE, a new handle will be created.
1267 int connect (ACE_HANDLE connect_handle
,
1268 const ACE_Addr
&remote_sap
,
1269 const ACE_Addr
&local_sap
,
1273 int signal_number
= 0);
1276 * Cancel all pending pseudo-asynchronus requests
1277 * Behavior as usual AIO request
1282 * Close performs cancellation of all pending requests
1283 * and close the connect handle
1287 /// Virtual from ACE_Event_Handler
1288 ACE_HANDLE
get_handle (void) const;
1290 /// Virtual from ACE_Event_Handler
1291 void set_handle (ACE_HANDLE handle
);
1293 /// Virtual from ACE_Event_Handler
1294 int handle_input ( ACE_HANDLE handle
);
1295 int handle_output ( ACE_HANDLE handle
);
1296 int handle_exception ( ACE_HANDLE handle
);
1298 /// Virtual from ACE_Event_Handler
1299 int handle_close (ACE_HANDLE handle
, ACE_Reactor_Mask close_mask
) ;
1301 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
1302 // methods are defined here to avoid dominace warnings. They route
1303 // the call to the ACE_WIN32_Asynch_Operation base class.
1304 /// Return the underlying proactor.
1305 ACE_Proactor
* proactor (void) const;
1308 int connect_i (ACE_WIN32_Asynch_Connect_Result
*result
,
1309 const ACE_Addr
&remote_sap
,
1310 const ACE_Addr
&local_sap
,
1313 int post_result (ACE_WIN32_Asynch_Connect_Result
*result
, bool flg_post
);
1315 /// Cancel uncompleted connect operations.
1317 * @param flg_notify Indicates whether or not to send notification about
1318 * canceled connect operations. If false, don't send
1319 * notifications. If true, notify user about canceled
1321 * According WIN32 standards we should receive
1322 * notifications on canceled AIO requests.
1324 * @param set Receives the set of I/O handles on which asynchronous
1325 * connect requests were canceled as a result of this
1326 * method. The contents of @a set are completely
1329 int cancel_uncompleted (bool flg_notify
, ACE_Handle_Set
&set
);
1331 /// true - Connect is registered in ACE_Asynch_Pseudo_Task
1332 /// false - Accept is deregisted in ACE_Asynch_Pseudo_Task
1335 typedef ACE_Map_Manager
<ACE_HANDLE
, ACE_WIN32_Asynch_Connect_Result
*, ACE_SYNCH_NULL_MUTEX
>
1338 /// Map of Result pointers that correspond to all the <accept>'s
1340 MAP_MANAGER result_map_
;
1342 /// The lock to protect the result map which is shared. The queue
1343 /// is updated by main thread in the register function call and
1344 /// through the auxillary thread in the asynch pseudo task.
1345 ACE_SYNCH_MUTEX lock_
;
1349 * @class ACE_WIN32_Asynch_Transmit_File_Result
1352 * @brief This class implements ACE_Asynch_Transmit_File::Result for
1355 * This class has all the information necessary for the
1356 * @a handler to uniquiely identify the completion of the
1357 * asynchronous transmit file.
1359 class ACE_Export ACE_WIN32_Asynch_Transmit_File_Result
: public virtual ACE_Asynch_Transmit_File_Result_Impl
,
1360 public ACE_WIN32_Asynch_Result
1362 /// Factory class will have special permission.
1363 friend class ACE_WIN32_Asynch_Transmit_File
;
1365 /// Proactor class has special permission.
1366 friend class ACE_WIN32_Proactor
;
1369 /// Socket used for transmitting the file.
1370 ACE_HANDLE
socket (void) const;
1372 /// File from which the data is read.
1373 ACE_HANDLE
file (void) const;
1375 /// Header and trailer data associated with this transmit file.
1376 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer (void) const;
1378 /// The number of bytes which were requested at the start of the
1379 /// asynchronous transmit file.
1380 size_t bytes_to_write (void) const;
1382 /// Number of bytes per send requested at the start of the transmit
1384 size_t bytes_per_send (void) const;
1386 /// Flags which were passed into transmit file.
1387 u_long
flags (void) const;
1389 // Base class operations. These operations are here to kill some
1390 // warnings. These methods call the base class methods.
1392 /// Number of bytes transferred by the operation.
1393 size_t bytes_transferred (void) const;
1395 /// ACT associated with the operation.
1396 const void *act (void) const;
1398 /// Did the operation succeed?
1399 int success (void) const;
1402 * This returns the ACT associated with the handle when it was
1403 * registered with the I/O completion port. This ACT is not the
1404 * same as the ACT associated with the asynchronous operation.
1406 const void *completion_key (void) const;
1408 /// Error value if the operation fail.
1409 u_long
error (void) const;
1411 /// Event associated with the OVERLAPPED structure.
1412 ACE_HANDLE
event (void) const;
1414 /// This really make sense only when doing file I/O.
1415 u_long
offset (void) const;
1417 /// Offset_high associated with the OVERLAPPED structure.
1418 u_long
offset_high (void) const;
1420 /// The priority of the asynchronous operation. Currently, this is
1421 /// not supported on Win32.
1422 int priority (void) const;
1424 /// No-op. Returns 0.
1425 int signal_number (void) const;
1427 /// Post @c this to the Proactor's completion port.
1428 int post_completion (ACE_Proactor_Impl
*proactor
);
1431 /// Constructor is protected since creation is limited to
1432 /// ACE_Asynch_Transmit_File factory.
1433 ACE_WIN32_Asynch_Transmit_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1436 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer
,
1437 size_t bytes_to_write
,
1440 size_t bytes_per_send
,
1445 int signal_number
= 0);
1447 /// Proactor will call this method when the write completes.
1448 virtual void complete (size_t bytes_transferred
,
1450 const void *completion_key
,
1454 virtual ~ACE_WIN32_Asynch_Transmit_File_Result (void);
1456 /// Network I/O handle.
1459 /// File I/O handle.
1462 /// Header and trailer data associated with this transmit file.
1463 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer_
;
1465 /// The number of bytes which were requested at the start of the
1466 /// asynchronous transmit file.
1467 size_t bytes_to_write_
;
1469 /// Number of bytes per send requested at the start of the transmit
1471 size_t bytes_per_send_
;
1473 /// Flags which were passed into transmit file.
1478 * @class ACE_WIN32_Asynch_Transmit_File
1480 * @brief This class is a factory for starting off asynchronous
1481 * transmit files on a stream.
1483 * Once <open> is called, multiple asynchronous <transmit_file>s
1484 * can started using this class. A
1485 * ACE_Asynch_Transmit_File::Result will be passed back to the
1486 * @a handler when the asynchronous transmit file completes
1487 * through the <ACE_Handler::handle_transmit_file> callback.
1489 * The transmit_file function transmits file data over a
1490 * connected network connection. The function uses the operating
1491 * system's cache manager to retrieve the file data. This
1492 * function provides high-performance file data transfer over
1493 * network connections. This function would be of great use in
1494 * a Web Server, Image Server, etc.
1496 class ACE_Export ACE_WIN32_Asynch_Transmit_File
: public virtual ACE_Asynch_Transmit_File_Impl
,
1497 public ACE_WIN32_Asynch_Operation
1501 ACE_WIN32_Asynch_Transmit_File (ACE_WIN32_Proactor
*win32_proactor
);
1504 * This starts off an asynchronous transmit file. The <file> is a
1505 * handle to an open file. <header_and_trailer> is a pointer to a
1506 * data structure that contains pointers to data to send before and
1507 * after the file data is sent. Set this parameter to 0 if you only
1508 * want to transmit the file data. Upto @a bytes_to_write will be
1509 * written to the <socket>. If you want to send the entire file,
1510 * let @a bytes_to_write = 0. @a bytes_per_send is the size of each
1511 * block of data sent per send operation. Please read the Win32
1512 * documentation on what the flags should be.
1514 int transmit_file (ACE_HANDLE file
,
1515 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer
,
1516 size_t bytes_to_write
,
1519 size_t bytes_per_send
,
1523 int signal_number
= 0);
1526 ~ACE_WIN32_Asynch_Transmit_File (void);
1528 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1529 // methods are defined here to avoid VC++ warnings. They route the
1530 // call to the ACE_WIN32_Asynch_Operation base class.
1533 * Initializes the factory with information which will be used with
1534 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1535 * <ACE_Handler::handle> will be called on the @a handler to get the
1538 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1540 const void *completion_key
,
1541 ACE_Proactor
*proactor
);
1544 * This cancels all pending accepts operations that were issued by
1545 * the calling thread. The function does not cancel asynchronous
1546 * operations issued by other threads.
1550 /// Return the underlying proactor.
1551 ACE_Proactor
* proactor (void) const;
1555 * @class ACE_WIN32_Asynch_Read_Dgram_Result
1557 * @brief This class provides concrete implementation for
1558 * ACE_Asynch_Read_Dgram::Result class.
1560 class ACE_Export ACE_WIN32_Asynch_Read_Dgram_Result
: public virtual ACE_Asynch_Read_Dgram_Result_Impl
,
1561 public ACE_WIN32_Asynch_Result
1563 /// Factory class will have special permissions.
1564 friend class ACE_WIN32_Asynch_Read_Dgram
;
1566 /// Proactor class has special permission.
1567 friend class ACE_WIN32_Proactor
;
1570 /// The number of bytes which were requested at the start of the
1571 /// asynchronous read.
1572 size_t bytes_to_read (void) const;
1574 /// Message block which contains the read data
1575 ACE_Message_Block
*message_block (void) const;
1577 /// The address of where the packet came from
1578 int remote_address (ACE_Addr
& addr
) const;
1580 sockaddr
*saddr () const;
1582 /// The flags used in the read
1583 int flags (void) const;
1585 /// I/O handle used for reading.
1586 ACE_HANDLE
handle (void) const;
1588 // Base class operations. These operations are here to kill
1589 // dominance warnings. These methods call the base class methods.
1591 /// Number of bytes transferred by the operation.
1592 size_t bytes_transferred (void) const;
1594 /// ACT associated with the operation.
1595 const void *act (void) const;
1597 /// Did the operation succeed?
1598 int success (void) const;
1601 * This returns the ACT associated with the handle when it was
1602 * registered with the I/O completion port. This ACT is not the
1603 * same as the ACT associated with the asynchronous operation.
1605 const void *completion_key (void) const;
1607 /// Error value if the operation fail.
1608 u_long
error (void) const;
1610 /// Event associated with the OVERLAPPED structure.
1611 ACE_HANDLE
event (void) const;
1613 /// This really make sense only when doing file I/O.
1614 u_long
offset (void) const;
1616 /// Offset_high associated with the OVERLAPPED structure.
1617 u_long
offset_high (void) const;
1619 /// The priority of the asynchronous operation. Currently, this is
1620 /// not supported on Win32.
1621 int priority (void) const;
1623 /// No-op. Returns 0.
1624 int signal_number (void) const;
1626 /// Post @c this to the Proactor's completion port.
1627 int post_completion (ACE_Proactor_Impl
*proactor
);
1630 /// Constructor is protected since creation is limited to
1631 /// ACE_Asynch_Read_Dgram factory.
1632 ACE_WIN32_Asynch_Read_Dgram_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1634 ACE_Message_Block
*message_block
,
1635 size_t bytes_to_read
,
1637 int protocol_family
,
1641 int signal_number
= 0);
1643 /// Proactor will call this method when the read completes.
1644 virtual void complete (size_t bytes_transferred
,
1646 const void *completion_key
,
1650 virtual ~ACE_WIN32_Asynch_Read_Dgram_Result (void);
1652 /// Bytes requested when the asynchronous read was initiated.
1653 size_t bytes_to_read_
;
1655 /// Message block for reading the data into.
1656 ACE_Message_Block
*message_block_
;
1658 /// The address of where the packet came from
1659 ACE_Addr
*remote_address_
;
1663 /// The flags used in the read
1666 /// I/O handle used for reading.
1671 * @class ACE_WIN32_Asynch_Read_Dgram
1673 * @brief This class is a factory for starting off asynchronous reads
1676 * Once <open> is called, multiple asynchronous <read>s can be
1677 * started using this class. An ACE_Asynch_Read_Dgram::Result
1678 * will be passed back to the @a handler when the asynchronous
1679 * reads completes through the <ACE_Handler::handle_read_stream>
1683 class ACE_Export ACE_WIN32_Asynch_Read_Dgram
: public virtual ACE_Asynch_Read_Dgram_Impl
,
1684 public ACE_WIN32_Asynch_Operation
1688 ACE_WIN32_Asynch_Read_Dgram (ACE_WIN32_Proactor
*win32_proactor
);
1691 virtual ~ACE_WIN32_Asynch_Read_Dgram (void);
1693 /** This starts off an asynchronous read. Upto
1694 * <message_block->total_size()> will be read and stored in the
1695 * @a message_block. @a message_block's <wr_ptr> will be updated to reflect
1696 * the added bytes if the read operation is successfully completed.
1697 * Return code of 1 means immediate success and <number_of_bytes_recvd>
1698 * will contain number of bytes read. The <ACE_Handler::handle_read_dgram>
1699 * method will still be called. Return code of 0 means the IO will
1700 * complete proactively. Return code of -1 means there was an error, use
1701 * errno to get the error code.
1703 * Scatter/gather is supported on WIN32 by using the <message_block->cont()>
1704 * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto
1705 * <message_block->size()> bytes will be read into each <message block> for
1706 * a total of <message_block->total_size()> bytes. All @a message_block's
1707 * <wr_ptr>'s will be updated to reflect the added bytes for each
1710 virtual ssize_t
recv (ACE_Message_Block
*message_block
,
1711 size_t &number_of_bytes_recvd
,
1713 int protocol_family
,
1718 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1719 // methods are defined here to avoid VC++ warnings. They route the
1720 // call to the ACE_WIN32_Asynch_Operation base class.
1723 * Initializes the factory with information which will be used with
1724 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1725 * <ACE_Handler::handle> will be called on the @a handler to get the
1728 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1730 const void *completion_key
,
1731 ACE_Proactor
*proactor
);
1734 * This cancels all pending accepts operations that were issued by
1735 * the calling thread. The function does not cancel asynchronous
1736 * operations issued by other threads.
1740 /// Return the underlying proactor.
1741 ACE_Proactor
* proactor (void) const;
1744 /// Do-nothing constructor.
1745 ACE_WIN32_Asynch_Read_Dgram (void);
1749 * @class ACE_WIN32_Asynch_Write_Dgram_Result
1751 * @brief This class provides concrete implementation for
1752 * ACE_Asynch_Write_Dgram::Result class.
1754 class ACE_Export ACE_WIN32_Asynch_Write_Dgram_Result
: public virtual ACE_Asynch_Write_Dgram_Result_Impl
,
1755 public ACE_WIN32_Asynch_Result
1757 /// Factory class willl have special permissions.
1758 friend class ACE_WIN32_Asynch_Write_Dgram
;
1760 /// Proactor class has special permission.
1761 friend class ACE_WIN32_Proactor
;
1764 /// The number of bytes which were requested at the start of the
1765 /// asynchronous write.
1766 size_t bytes_to_write (void) const;
1768 /// Message block which contains the sent data
1769 ACE_Message_Block
*message_block (void) const;
1771 /// The flags using in the write
1772 int flags (void) const;
1774 /// I/O handle used for writing.
1775 ACE_HANDLE
handle (void) const;
1777 // = Base class operations. These operations are here to kill some
1778 // warnings. These methods call the base class methods.
1780 /// Number of bytes transferred by the operation.
1781 size_t bytes_transferred (void) const;
1783 /// ACT associated with the operation.
1784 const void *act (void) const;
1786 /// Did the operation succeed?
1787 int success (void) const;
1790 * This returns the ACT associated with the handle when it was
1791 * registered with the I/O completion port. This ACT is not the
1792 * same as the ACT associated with the asynchronous operation.
1794 const void *completion_key (void) const;
1796 /// Error value if the operation fail.
1797 u_long
error (void) const;
1799 /// Event associated with the OVERLAPPED structure.
1800 ACE_HANDLE
event (void) const;
1802 /// This really make sense only when doing file I/O.
1803 u_long
offset (void) const;
1805 /// Offset_high associated with the OVERLAPPED structure.
1806 u_long
offset_high (void) const;
1808 /// The priority of the asynchronous operation. Currently, this is
1809 /// not supported on Win32.
1810 int priority (void) const;
1812 /// No-op. Returns 0.
1813 int signal_number (void) const;
1815 /// Post @c this to the Proactor's completion port.
1816 int post_completion (ACE_Proactor_Impl
*proactor
);
1819 /// Constructor is protected since creation is limited to
1820 /// ACE_Asynch_Write_Stream factory.
1821 ACE_WIN32_Asynch_Write_Dgram_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1823 ACE_Message_Block
*message_block
,
1824 size_t bytes_to_write
,
1829 int signal_number
= 0);
1831 /// ACE_Proactor will call this method when the write completes.
1832 virtual void complete (size_t bytes_transferred
,
1834 const void *completion_key
,
1838 virtual ~ACE_WIN32_Asynch_Write_Dgram_Result (void);
1840 /// The number of bytes which were requested at the start of the
1841 /// asynchronous write.
1842 size_t bytes_to_write_
;
1844 /// Message block used for the send.
1845 ACE_Message_Block
*message_block_
;
1847 /// The flags using in the write
1850 /// I/O handle used for writing.
1855 * @class ACE_WIN32_Asynch_Write_Dgram
1857 * @brief This class is a factory for starting off asynchronous writes
1861 * Once <open> is called, multiple asynchronous <writes>s can
1862 * started using this class. A ACE_Asynch_Write_Stream::Result
1863 * will be passed back to the @a handler when the asynchronous
1864 * write completes through the
1865 * <ACE_Handler::handle_write_stream> callback.
1867 class ACE_Export ACE_WIN32_Asynch_Write_Dgram
: public virtual ACE_Asynch_Write_Dgram_Impl
,
1868 public ACE_WIN32_Asynch_Operation
1872 ACE_WIN32_Asynch_Write_Dgram (ACE_WIN32_Proactor
*win32_proactor
);
1875 virtual ~ACE_WIN32_Asynch_Write_Dgram (void);
1877 /** This starts off an asynchronous send. Upto
1878 * <message_block->total_length()> will be sent. @a message_block's
1879 * <rd_ptr> will be updated to reflect the sent bytes if the send operation
1880 * is successfully completed.
1881 * Return code of 1 means immediate success and <number_of_bytes_sent>
1882 * is updated to number of bytes sent. The <ACE_Handler::handle_write_dgram>
1883 * method will still be called. Return code of 0 means the IO will
1884 * complete proactively. Return code of -1 means there was an error, use
1885 * errno to get the error code.
1887 * Scatter/gather is supported on WIN32 by using the <message_block->cont()>
1888 * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto
1889 * <message_block->length()> bytes will be sent from each <message block>
1890 * for a total of <message_block->total_length()> bytes. All
1891 * @a message_block's <rd_ptr>'s will be updated to reflect the bytes sent
1892 * from each @a message_block.
1894 virtual ssize_t
send (ACE_Message_Block
*message_block
,
1895 size_t &number_of_bytes_sent
,
1897 const ACE_Addr
&addr
,
1902 // = Methods belonging to <ACE_WIN32_Asynch_Operation> base class.
1904 // These methods are defined here to avoid VC++ warnings. They route
1905 // the call to the <ACE_WIN32_Asynch_Operation> base class.
1908 * Initializes the factory with information which will be used with
1909 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1910 * <ACE_Handler::handle> will be called on the @a handler to get the
1913 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1915 const void *completion_key
,
1916 ACE_Proactor
*proactor
);
1919 * This cancels all pending accepts operations that were issued by
1920 * the calling thread. The function does not cancel asynchronous
1921 * operations issued by other threads.
1925 /// Return the underlying proactor.
1926 ACE_Proactor
* proactor (void) const;
1929 /// Do-nothing constructor.
1930 ACE_WIN32_Asynch_Write_Dgram (void);
1933 ACE_END_VERSIONED_NAMESPACE_DECL
1935 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO && ACE_HAS_WINSOCK2 */
1936 #include /**/ "ace/post.h"
1937 #endif /* ACE_WIN32_ASYNCH_IO_H */