3 //=============================================================================
5 * @file WIN32_Asynch_IO.h
7 * These classes only works on Win32 platforms.
9 * The implementation of ACE_Asynch_Transmit_File,
10 * ACE_Asynch_Accept, and ACE_Asynch_Connect are only supported if
11 * ACE_HAS_WINSOCK2 is defined or you are on WinNT 4.0 or higher.
13 * @author Irfan Pyarali <irfan@cs.wustl.edu>
14 * @author Tim Harrison <harrison@cs.wustl.edu>
15 * @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
16 * @author Roger Tragin <r.tragin@computer.org>
17 * @author Alexander Libman <alibman@ihug.com.au>
19 //=============================================================================
21 #ifndef ACE_WIN32_ASYNCH_IO_H
22 #define ACE_WIN32_ASYNCH_IO_H
23 #include /**/ "ace/pre.h"
25 #include /**/ "ace/config-all.h"
27 #if !defined (ACE_LACKS_PRAGMA_ONCE)
29 #endif /* ACE_LACKS_PRAGMA_ONCE */
31 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) && \
32 (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 == 1))
34 #include "ace/Asynch_IO_Impl.h"
36 #include "ace/Event_Handler.h"
37 #include "ace/Handle_Set.h"
38 #include "ace/Map_Manager.h"
39 #include "ace/Null_Mutex.h"
41 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
43 // Forward declaration
44 class ACE_WIN32_Proactor
;
47 * @class ACE_WIN32_Asynch_Result
49 * @brief An abstract class which adds information to the OVERLAPPED
50 * structure to make it more useful.
52 * An abstract base class from which you can obtain some basic
53 * information like the number of bytes transferred, the ACT
54 * associated with the asynchronous operation, indication of
55 * success or failure, etc. Subclasses may want to store more
56 * information that is particular to the asynchronous operation
59 class ACE_Export ACE_WIN32_Asynch_Result
: public virtual ACE_Asynch_Result_Impl
,
62 /// Factory class has special permissions.
63 friend class ACE_WIN32_Asynch_Accept
;
65 /// Proactor class has special permission.
66 friend class ACE_WIN32_Proactor
;
69 /// Number of bytes transferred by the operation.
70 size_t bytes_transferred (void) const;
72 /// ACT associated with the operation.
73 const void *act (void) const;
75 /// Did the operation succeed?
76 int success (void) const;
79 * This returns the ACT associated with the handle when it was
80 * registered with the I/O completion port. This ACT is not the
81 * same as the ACT associated with the asynchronous operation.
83 const void *completion_key (void) const;
85 /// Error value if the operation fail.
86 u_long
error (void) const;
88 /// Event associated with the OVERLAPPED structure.
89 ACE_HANDLE
event (void) const;
91 /// This really make sense only when doing file I/O.
92 u_long
offset (void) const;
94 /// Offset_high associated with the OVERLAPPED structure.
95 u_long
offset_high (void) const;
97 /// The priority of the asynchronous operation. Currently, this is
98 /// not supported on Win32.
99 int priority (void) const;
102 int signal_number (void) const;
104 /// Post @c this to the Proactor's completion port.
105 int post_completion (ACE_Proactor_Impl
*proactor
);
108 virtual ~ACE_WIN32_Asynch_Result (void);
110 /// Simulate error value to use in the post_completion()
111 void set_error (u_long errcode
);
113 /// Simulate value to use in the post_completion()
114 void set_bytes_transferred (size_t nbytes
);
118 ACE_WIN32_Asynch_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
124 int signal_number
= 0);
126 /// Proxy for the ACE_Handler that will be called back.
127 ACE_Handler::Proxy_Ptr handler_proxy_
;
129 /// ACT for this operation.
132 /// Bytes transferred by this operation.
133 size_t bytes_transferred_
;
135 /// Success indicator.
138 /// ACT associated with handle.
139 const void *completion_key_
;
141 /// Error if operation failed.
146 * @class ACE_WIN32_Asynch_Operation
148 * @brief This class abstracts out the common things needed for
149 * implementing Asynch_Operation for WIN32 platform.
151 class ACE_Export ACE_WIN32_Asynch_Operation
: public virtual ACE_Asynch_Operation_Impl
155 * Initializes the factory with information which will be used with
156 * each asynchronous call. If (@a handle == ACE_INVALID_HANDLE),
157 * ACE_Handler::handle() will be called on the @a handler to get the
160 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
162 const void *completion_key
,
163 ACE_Proactor
*proactor
);
166 * This cancels all pending accepts operations that were issued by
167 * the calling thread. The function does not cancel asynchronous
168 * operations issued by other threads.
174 /// Return the underlying proactor.
175 ACE_Proactor
* proactor (void) const;
179 ACE_WIN32_Asynch_Operation (ACE_WIN32_Proactor
*win32_proactor
);
182 virtual ~ACE_WIN32_Asynch_Operation (void);
185 ACE_WIN32_Proactor
*win32_proactor_
;
187 /// Proactor that this asynch IO is registered with.
188 ACE_Proactor
*proactor_
;
190 /// Handler that will receive the callback.
191 ACE_Handler::Proxy_Ptr handler_proxy_
;
193 /// I/O handle used for reading.
198 * @class ACE_WIN32_Asynch_Read_Stream_Result
200 * @brief This class provides concrete implementation for
201 * ACE_Asynch_Read_Stream::Result class.
203 class ACE_Export ACE_WIN32_Asynch_Read_Stream_Result
: public virtual ACE_Asynch_Read_Stream_Result_Impl
,
204 public ACE_WIN32_Asynch_Result
206 /// Factory class will have special permissions.
207 friend class ACE_WIN32_Asynch_Read_Stream
;
209 /// Proactor class has special permission.
210 friend class ACE_WIN32_Proactor
;
213 /// The number of bytes which were requested at the start of the
214 /// asynchronous read.
215 size_t bytes_to_read (void) const;
217 /// Message block which contains the read data.
218 ACE_Message_Block
&message_block (void) const;
220 /// I/O handle used for reading.
221 ACE_HANDLE
handle (void) const;
223 // Base class operations. These operations are here to kill
224 // dominance warnings. These methods call the base class methods.
226 /// Number of bytes transferred by the operation.
227 size_t bytes_transferred (void) const;
229 /// ACT associated with the operation.
230 const void *act (void) const;
232 /// Did the operation succeed?
233 int success (void) const;
236 * This returns the ACT associated with the handle when it was
237 * registered with the I/O completion port. This ACT is not the
238 * same as the ACT associated with the asynchronous operation.
240 const void *completion_key (void) const;
242 /// Error value if the operation fail.
243 u_long
error (void) const;
245 /// Event associated with the OVERLAPPED structure.
246 ACE_HANDLE
event (void) const;
248 /// This really make sense only when doing file I/O.
249 u_long
offset (void) const;
251 /// Offset_high associated with the OVERLAPPED structure.
252 u_long
offset_high (void) const;
254 /// The priority of the asynchronous operation. Currently, this is
255 /// not supported on Win32.
256 int priority (void) const;
258 /// No-op. Returns 0.
259 int signal_number (void) const;
261 /// Post @c this to the Proactor's completion port.
262 int post_completion (ACE_Proactor_Impl
*proactor
);
264 /// Accessor for the scatter read flag
265 int scatter_enabled (void) const;
268 /// Constructor is protected since creation is limited to
269 /// ACE_Asynch_Read_Stream factory.
270 ACE_WIN32_Asynch_Read_Stream_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
272 ACE_Message_Block
&message_block
,
273 size_t bytes_to_read
,
277 int signal_number
= 0,
278 int scatter_enabled
= 0);
280 /// Proactor will call this method when the read completes.
281 virtual void complete (size_t bytes_transferred
,
283 const void *completion_key
,
287 virtual ~ACE_WIN32_Asynch_Read_Stream_Result (void);
289 /// Bytes requested when the asynchronous read was initiated.
290 size_t bytes_to_read_
;
292 /// Message block for reading the data into.
293 ACE_Message_Block
&message_block_
;
295 /// I/O handle used for reading.
298 /// Flag for scatter read
299 int scatter_enabled_
;
303 * @class ACE_WIN32_Asynch_Read_Stream
305 * @brief This class is a factory for starting off asynchronous reads
308 * Once open() is called, multiple asynchronous read()s can
309 * started using this class. An ACE_Asynch_Read_Stream::Result
310 * will be passed back to the @a handler when the asynchronous
311 * reads completes through the <ACE_Handler::handle_read_stream>
314 class ACE_Export ACE_WIN32_Asynch_Read_Stream
: public virtual ACE_Asynch_Read_Stream_Impl
,
315 public ACE_WIN32_Asynch_Operation
320 ACE_WIN32_Asynch_Read_Stream (ACE_WIN32_Proactor
*win32_proactor
);
322 /// This starts off an asynchronous read. Upto @a bytes_to_read will
323 /// be read and stored in the @a message_block.
324 int read (ACE_Message_Block
&message_block
,
325 size_t bytes_to_read
,
328 int signal_number
= 0);
331 * Same as above but with scatter support, through chaining of composite
332 * message blocks using the continuation field.
334 int readv (ACE_Message_Block
&message_block
,
335 size_t bytes_to_read
,
338 int signal_number
= 0);
341 virtual ~ACE_WIN32_Asynch_Read_Stream (void);
343 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
344 // methods are defined here to avoid VC++ warnings. They route the
345 // call to the ACE_WIN32_Asynch_Operation base class.
348 * Initializes the factory with information which will be used with
349 * each asynchronous call. If (@a handle == ACE_INVALID_HANDLE),
350 * ACE_Handler::handle() will be called on the @a handler to get the
353 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
355 const void *completion_key
,
356 ACE_Proactor
*proactor
);
359 * This cancels all pending accepts operations that were issued by
360 * the calling thread. The function does not cancel asynchronous
361 * operations issued by other threads.
365 /// Return the underlying proactor.
366 ACE_Proactor
* proactor (void) const;
369 /// This is the method which does the real work and is there so that
370 /// the ACE_Asynch_Read_File class can use it too.
371 int shared_read (ACE_WIN32_Asynch_Read_Stream_Result
*result
);
375 * @class ACE_WIN32_Asynch_Write_Stream_Result
377 * @brief This class provides concrete implementation for
378 * ACE_Asynch_Write_Stream::Result class.
380 class ACE_Export ACE_WIN32_Asynch_Write_Stream_Result
: public virtual ACE_Asynch_Write_Stream_Result_Impl
,
381 public ACE_WIN32_Asynch_Result
383 /// Factory class willl have special permissions.
384 friend class ACE_WIN32_Asynch_Write_Stream
;
386 /// Proactor class has special permission.
387 friend class ACE_WIN32_Proactor
;
390 /// The number of bytes which were requested at the start of the
391 /// asynchronous write.
392 size_t bytes_to_write (void) const;
394 /// Message block that contains the data to be written.
395 ACE_Message_Block
&message_block (void) const;
397 /// I/O handle used for writing.
398 ACE_HANDLE
handle (void) const;
400 // = Base class operations. These operations are here to kill some
401 // warnings. These methods call the base class methods.
403 /// Number of bytes transferred by the operation.
404 size_t bytes_transferred (void) const;
406 /// ACT associated with the operation.
407 const void *act (void) const;
409 /// Did the operation succeed?
410 int success (void) const;
413 * This returns the ACT associated with the handle when it was
414 * registered with the I/O completion port. This ACT is not the
415 * same as the ACT associated with the asynchronous operation.
417 const void *completion_key (void) const;
419 /// Error value if the operation fail.
420 u_long
error (void) const;
422 /// Event associated with the OVERLAPPED structure.
423 ACE_HANDLE
event (void) const;
425 /// This really make sense only when doing file I/O.
426 u_long
offset (void) const;
428 /// Offset_high associated with the OVERLAPPED structure.
429 u_long
offset_high (void) const;
431 /// The priority of the asynchronous operation. Currently, this is
432 /// not supported on Win32.
433 int priority (void) const;
435 /// No-op. Returns 0.
436 int signal_number (void) const;
438 /// Post @c this to the Proactor's completion port.
439 int post_completion (ACE_Proactor_Impl
*proactor
);
441 /// Accessor for the gather write flag
442 int gather_enabled (void) const;
445 /// Constructor is protected since creation is limited to
446 /// ACE_Asynch_Write_Stream factory.
447 ACE_WIN32_Asynch_Write_Stream_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
449 ACE_Message_Block
&message_block
,
450 size_t bytes_to_write
,
454 int signal_number
= 0,
455 int gather_enabled
= 0);
457 /// ACE_Proactor will call this method when the write completes.
458 virtual void complete (size_t bytes_transferred
,
460 const void *completion_key
,
464 virtual ~ACE_WIN32_Asynch_Write_Stream_Result (void);
466 /// The number of bytes which were requested at the start of the
467 /// asynchronous write.
468 size_t bytes_to_write_
;
470 /// Message block that contains the data to be written.
471 ACE_Message_Block
&message_block_
;
473 /// I/O handle used for writing.
476 /// Flag for gather write
481 * @class ACE_WIN32_Asynch_Write_Stream
483 * @brief This class is a factory for starting off asynchronous writes
486 * Once open() is called, multiple asynchronous <writes>s can
487 * started using this class. A ACE_Asynch_Write_Stream::Result
488 * will be passed back to the @a handler when the asynchronous
489 * write completes through the
490 * ACE_Handler::handle_write_stream() callback.
492 class ACE_Export ACE_WIN32_Asynch_Write_Stream
: public virtual ACE_Asynch_Write_Stream_Impl
,
493 public ACE_WIN32_Asynch_Operation
497 ACE_WIN32_Asynch_Write_Stream (ACE_WIN32_Proactor
*win32_proactor
);
499 /// This starts off an asynchronous write. Upto @a bytes_to_write
500 /// will be written from the @a message_block.
501 int write (ACE_Message_Block
&message_block
,
502 size_t bytes_to_write
,
505 int signal_number
= 0);
508 * Same as above but with gather support, through chaining of composite
509 * message blocks using the continuation field.
511 int writev (ACE_Message_Block
&message_block
,
512 size_t bytes_to_write
,
515 int signal_number
= 0);
518 virtual ~ACE_WIN32_Asynch_Write_Stream (void);
520 // = Methods belonging to <ACE_WIN32_Asynch_Operation> base class.
522 // These methods are defined here to avoid VC++ warnings. They route
523 // the call to the <ACE_WIN32_Asynch_Operation> base class.
526 * Initializes the factory with information which will be used with
527 * each asynchronous call. If (@a handle == ACE_INVALID_HANDLE),
528 * ACE_Handler::handle() will be called on the @a handler to get the
531 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
533 const void *completion_key
,
534 ACE_Proactor
*proactor
);
537 * This cancels all pending accepts operations that were issued by
538 * the calling thread. The function does not cancel asynchronous
539 * operations issued by other threads.
543 /// Return the underlying proactor.
544 ACE_Proactor
* proactor (void) const;
548 * @class ACE_WIN32_Asynch_Read_File_Result
550 * @brief This class provides concrete implementation for
551 * ACE_Asynch_Read_File::Result class.
553 class ACE_Export ACE_WIN32_Asynch_Read_File_Result
: public virtual ACE_Asynch_Read_File_Result_Impl
,
554 public ACE_WIN32_Asynch_Read_Stream_Result
556 /// Factory class will have special permissions.
557 friend class ACE_WIN32_Asynch_Read_File
;
559 /// Proactor class has special permission.
560 friend class ACE_WIN32_Proactor
;
563 // = These methods belong to ACE_WIN32_Asynch_Result class base
564 // class. These operations are here to kill some warnings. These
565 // methods call the base class methods.
567 /// Number of bytes transferred by the operation.
568 size_t bytes_transferred (void) const;
570 /// ACT associated with the operation.
571 const void *act (void) const;
573 /// Did the operation succeed?
574 int success (void) const;
577 * This returns the ACT associated with the handle when it was
578 * registered with the I/O completion port. This ACT is not the
579 * same as the ACT associated with the asynchronous operation.
581 const void *completion_key (void) const;
583 /// Error value if the operation fail.
584 u_long
error (void) const;
586 /// Event associated with the OVERLAPPED structure.
587 ACE_HANDLE
event (void) const;
589 /// This really make sense only when doing file I/O.
590 u_long
offset (void) const;
592 /// Offset_high associated with the OVERLAPPED structure.
593 u_long
offset_high (void) const;
595 /// The priority of the asynchronous operation. Currently, this is
596 /// not supported on Win32.
597 int priority (void) const;
599 /// No-op. Returns 0.
600 int signal_number (void) const;
602 // The following methods belong to
603 // ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++
604 // dominance warnings. These methods route their call to the
605 // ACE_WIN32_Asynch_Read_Stream_Result base class.
607 /// The number of bytes which were requested at the start of the
608 /// asynchronous read.
609 size_t bytes_to_read (void) const;
611 /// Message block which contains the read data.
612 ACE_Message_Block
&message_block (void) const;
614 /// I/O handle used for reading.
615 ACE_HANDLE
handle (void) const;
617 /// Post @c this to the Proactor's completion port.
618 int post_completion (ACE_Proactor_Impl
*proactor
);
621 /// Constructor is protected since creation is limited to
622 /// ACE_Asynch_Read_File factory.
623 ACE_WIN32_Asynch_Read_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
625 ACE_Message_Block
&message_block
,
626 size_t bytes_to_read
,
632 int signal_number
= 0,
633 int scatter_enabled
= 0);
635 /// ACE_Proactor will call this method when the read completes.
636 virtual void complete (size_t bytes_transferred
,
638 const void *completion_key
,
642 virtual ~ACE_WIN32_Asynch_Read_File_Result (void);
646 * @class ACE_WIN32_Asynch_Read_File
648 * @brief This class is a factory for starting off asynchronous reads
651 * Once <open> is called, multiple asynchronous <read>s can
652 * started using this class. A ACE_Asynch_Read_File::Result
653 * will be passed back to the @a handler when the asynchronous
654 * reads completes through the <ACE_Handler::handle_read_file>
657 * This class differs slightly from ACE_Asynch_Read_Stream as it
658 * allows the user to specify an offset for the read.
660 class ACE_Export ACE_WIN32_Asynch_Read_File
: public virtual ACE_Asynch_Read_File_Impl
,
661 public ACE_WIN32_Asynch_Read_Stream
666 ACE_WIN32_Asynch_Read_File (ACE_WIN32_Proactor
*win32_proactor
);
669 * This starts off an asynchronous read. Upto @a bytes_to_read will
670 * be read and stored in the @a message_block. The read will start
671 * at @a offset from the beginning of the file.
673 int read (ACE_Message_Block
&message_block
,
674 size_t bytes_to_read
,
679 int signal_number
= 0);
682 * Same as above but with scatter support, through chaining of
683 * composite message blocks using the continuation field.
684 * @note Each data block payload must be at least the size of a
685 * system memory page and must be aligned on a system memory page
688 int readv (ACE_Message_Block
&message_block
,
689 size_t bytes_to_read
,
694 int signal_number
= 0);
698 virtual ~ACE_WIN32_Asynch_Read_File (void);
700 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
701 // methods are defined here to avoid VC++ warnings. They route the
702 // call to the ACE_WIN32_Asynch_Operation base class.
705 * Initializes the factory with information which will be used with
706 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
707 * <ACE_Handler::handle> will be called on the @a handler to get the
710 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
712 const void *completion_key
,
713 ACE_Proactor
*proactor
);
716 * This cancels all pending accepts operations that were issued by
717 * the calling thread. The function does not cancel asynchronous
718 * operations issued by other threads.
722 /// Return the underlying proactor.
723 ACE_Proactor
* proactor (void) const;
727 * This method belongs to ACE_WIN32_Asynch_Read_Stream. It is here
728 * to avoid the compiler warnings. We forward this call to the
729 * ACE_WIN32_Asynch_Read_Stream class.
731 int read (ACE_Message_Block
&message_block
,
732 size_t bytes_to_read
,
735 int signal_number
= 0);
738 * Same as above but with scatter support, through chaining of composite
739 * message blocks using the continuation field.
741 int readv (ACE_Message_Block
&message_block
,
742 size_t bytes_to_read
,
745 int signal_number
= 0);
749 * @class ACE_WIN32_Asynch_Write_File_Result
751 * @brief This class provides implementation for
752 * ACE_Asynch_Write_File_Result for WIN32 platforms.
754 * This class has all the information necessary for the
755 * @a handler to uniquiely identify the completion of the
756 * asynchronous write.
758 * This class differs slightly from
759 * ACE_Asynch_Write_Stream::Result as it calls back
760 * <ACE_Handler::handle_write_file> on the @a handler instead
761 * of <ACE_Handler::handle_write_stream>. No additional state
762 * is required by this class as ACE_Asynch_Result can store
765 class ACE_Export ACE_WIN32_Asynch_Write_File_Result
: public virtual ACE_Asynch_Write_File_Result_Impl
,
766 public ACE_WIN32_Asynch_Write_Stream_Result
768 /// Factory class will have special permission.
769 friend class ACE_WIN32_Asynch_Write_File
;
771 /// Proactor class has special permission.
772 friend class ACE_WIN32_Proactor
;
775 // = Base class operations. These operations are here to kill some
776 // warnings. These methods call the base class methods.
778 /// Number of bytes transferred by the operation.
779 size_t bytes_transferred (void) const;
781 /// ACT associated with the operation.
782 const void *act (void) const;
784 /// Did the operation succeed?
785 int success (void) const;
788 * This returns the ACT associated with the handle when it was
789 * registered with the I/O completion port. This ACT is not the
790 * same as the ACT associated with the asynchronous operation.
792 const void *completion_key (void) const;
794 /// Error value if the operation fail.
795 u_long
error (void) const;
797 /// Event associated with the OVERLAPPED structure.
798 ACE_HANDLE
event (void) const;
800 /// This really make sense only when doing file I/O.
801 u_long
offset (void) const;
803 /// Offset_high associated with the OVERLAPPED structure.
804 u_long
offset_high (void) const;
806 /// The priority of the asynchronous operation. Currently, this is
807 /// not supported on Win32.
808 int priority (void) const;
810 /// No-op. Returns 0.
811 int signal_number (void) const;
813 // The following methods belong to
814 // ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++
815 // warnings. These methods route their call to the
816 // ACE_WIN32_Asynch_Read_Stream_Result base class.
818 /// The number of bytes which were requested at the start of the
819 /// asynchronous write.
820 size_t bytes_to_write (void) const;
822 /// Message block that contains the data to be written.
823 ACE_Message_Block
&message_block (void) const;
825 /// I/O handle used for writing.
826 ACE_HANDLE
handle (void) const;
828 /// Post @c this to the Proactor's completion port.
829 int post_completion (ACE_Proactor_Impl
*proactor
);
832 /// Constructor is protected since creation is limited to
833 /// ACE_Asynch_Write_File factory.
834 ACE_WIN32_Asynch_Write_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
836 ACE_Message_Block
&message_block
,
837 size_t bytes_to_write
,
843 int signal_number
= 0,
844 int gather_enabled
= 0);
846 /// ACE_Proactor will call this method when the write completes.
847 virtual void complete (size_t bytes_transferred
,
849 const void *completion_key
,
853 virtual ~ACE_WIN32_Asynch_Write_File_Result (void);
857 * @class ACE_WIN32_Asynch_Write_File
859 * @brief This class is a factory for starting off asynchronous writes
862 * Once <open> is called, multiple asynchronous <write>s can be
863 * started using this class. A ACE_Asynch_Write_File::Result
864 * will be passed back to the @a handler when the asynchronous
865 * writes completes through the <ACE_Handler::handle_write_file>
868 class ACE_Export ACE_WIN32_Asynch_Write_File
: public virtual ACE_Asynch_Write_File_Impl
,
869 public ACE_WIN32_Asynch_Write_Stream
873 ACE_WIN32_Asynch_Write_File (ACE_WIN32_Proactor
*win32_proactor
);
876 * This starts off an asynchronous write. Upto @a bytes_to_write
877 * will be write and stored in the @a message_block. The write will
878 * start at @a offset from the beginning of the file.
880 int write (ACE_Message_Block
&message_block
,
881 size_t bytes_to_write
,
886 int signal_number
= 0);
889 * Same as above but with gather support, through chaining of
890 * composite message blocks using the continuation field.
891 * @note Each data block payload must be at least the size of a
892 * system memory page and must be aligned on a system memory page
895 int writev (ACE_Message_Block
&message_block
,
896 size_t bytes_to_write
,
901 int signal_number
= 0);
904 virtual ~ACE_WIN32_Asynch_Write_File (void);
906 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
907 // methods are defined here to avoid VC++ warnings. They route the
908 // call to the ACE_WIN32_Asynch_Operation base class.
911 * Initializes the factory with information which will be used with
912 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
913 * <ACE_Handler::handle> will be called on the @a handler to get the
916 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
918 const void *completion_key
,
919 ACE_Proactor
*proactor
);
922 * This cancels all pending accepts operations that were issued by
923 * the calling thread. The function does not cancel asynchronous
924 * operations issued by other threads.
928 /// Return the underlying proactor.
929 ACE_Proactor
* proactor (void) const;
933 * This method belongs to ACE_WIN32_Asynch_Write_Stream. It is here
934 * to avoid compiler warnings. This method is forwarded to the
935 * Write_File specific method with 0 offset values.
937 int write (ACE_Message_Block
&message_block
,
938 size_t bytes_to_write
,
941 int signal_number
= 0);
944 * Same as above but with gather support, through chaining of composite
945 * message blocks using the continuation field.
947 int writev (ACE_Message_Block
&message_block
,
948 size_t bytes_to_write
,
951 int signal_number
= 0);
955 * @class ACE_WIN32_Asynch_Accept_Result
957 * @brief This class implements ACE_Asynch_Accept::Result for WIN32
960 * This class has all the information necessary for the
961 * @a handler to uniquiely identify the completion of the
962 * asynchronous accept.
964 class ACE_Export ACE_WIN32_Asynch_Accept_Result
: public virtual ACE_Asynch_Accept_Result_Impl
,
965 public ACE_WIN32_Asynch_Result
967 /// Factory will have special permission.
968 friend class ACE_WIN32_Asynch_Accept
;
970 /// Proactor class has special permission.
971 friend class ACE_WIN32_Proactor
;
974 /// The number of bytes which were requested at the start of the
975 /// asynchronous accept.
976 size_t bytes_to_read (void) const;
978 /// Message block which contains the read data.
979 ACE_Message_Block
&message_block (void) const;
981 /// I/O handle used for accepting new connections.
982 ACE_HANDLE
listen_handle (void) const;
984 /// I/O handle for the new connection.
985 ACE_HANDLE
accept_handle (void) const;
987 // = Base class operations. These operations are here to kill some
988 // warnings. These methods call the base class methods.
990 /// Number of bytes transferred by the operation.
991 size_t bytes_transferred (void) const;
993 /// ACT associated with the operation.
994 const void *act (void) const;
996 /// Did the operation succeed?
997 int success (void) const;
1000 * This returns the ACT associated with the handle when it was
1001 * registered with the I/O completion port. This ACT is not the
1002 * same as the ACT associated with the asynchronous operation.
1004 const void *completion_key (void) const;
1006 /// Error value if the operation fail.
1007 u_long
error (void) const;
1009 /// Event associated with the OVERLAPPED structure.
1010 ACE_HANDLE
event (void) const;
1012 /// This really make sense only when doing file I/O.
1013 u_long
offset (void) const;
1015 /// Offset_high associated with the OVERLAPPED structure.
1016 u_long
offset_high (void) const;
1018 /// The priority of the asynchronous operation. Currently, this is
1019 /// not supported on Win32.
1020 int priority (void) const;
1022 /// No-op. Returns 0.
1023 int signal_number (void) const;
1025 /// Post @c this to the Proactor's completion port.
1026 int post_completion (ACE_Proactor_Impl
*proactor
);
1029 /// Constructor is protected since creation is limited to
1030 /// ACE_Asynch_Accept factory.
1031 ACE_WIN32_Asynch_Accept_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1032 ACE_HANDLE listen_handle
,
1033 ACE_HANDLE accept_handle
,
1034 ACE_Message_Block
&message_block
,
1035 size_t bytes_to_read
,
1039 int signal_number
= 0);
1041 /// ACE_Proactor will call this method when the accept completes.
1042 virtual void complete (size_t bytes_transferred
,
1044 const void *completion_key
,
1048 virtual ~ACE_WIN32_Asynch_Accept_Result (void);
1050 /// Bytes requested when the asynchronous read was initiated.
1051 size_t bytes_to_read_
;
1053 /// Message block for reading the data into.
1054 ACE_Message_Block
&message_block_
;
1056 /// I/O handle used for accepting new connections.
1057 ACE_HANDLE listen_handle_
;
1059 /// I/O handle for the new connection.
1060 ACE_HANDLE accept_handle_
;
1064 * @class ACE_WIN32_Asynch_Accept
1066 * @brief This class is a factory for starting off asynchronous accepts
1067 * on a listen handle.
1069 * Once <open> is called, multiple asynchronous <accept>s can
1070 * started using this class. A ACE_Asynch_Accept::Result will
1071 * be passed back to the @a handler when the asynchronous accept
1072 * completes through the <ACE_Handler::handle_accept>
1075 class ACE_Export ACE_WIN32_Asynch_Accept
: public virtual ACE_Asynch_Accept_Impl
,
1076 public ACE_WIN32_Asynch_Operation
1080 ACE_WIN32_Asynch_Accept (ACE_WIN32_Proactor
*win32_proactor
);
1083 * This starts off an asynchronous accept. The asynchronous accept
1084 * call also allows any initial data to be returned to the
1085 * @a handler. Upto @a bytes_to_read will be read and stored in the
1086 * @a message_block. The <accept_handle> will be used for the
1087 * <accept> call. If (<accept_handle> == INVALID_HANDLE), a new
1088 * handle will be created.
1090 * @a message_block must be specified. This is because the address of
1091 * the new connection is placed at the end of this buffer.
1093 int accept (ACE_Message_Block
&message_block
,
1094 size_t bytes_to_read
,
1095 ACE_HANDLE accept_handle
,
1098 int signal_number
= 0,
1099 int addr_family
= AF_INET
);
1102 ~ACE_WIN32_Asynch_Accept (void);
1104 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1105 // methods are defined here to avoid VC++ warnings. They route the
1106 // call to the ACE_WIN32_Asynch_Operation base class.
1109 * Initializes the factory with information which will be used with
1110 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1111 * <ACE_Handler::handle> will be called on the @a handler to get the
1114 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1116 const void *completion_key
,
1117 ACE_Proactor
*proactor
);
1120 * This cancels all pending accepts operations that were issued by
1121 * the calling thread. The function does not cancel asynchronous
1122 * operations issued by other threads.
1126 /// Return the underlying proactor.
1127 ACE_Proactor
* proactor (void) const;
1131 * @class ACE_WIN32_Asynch_Connect_Result
1133 * @brief This is that class which will be passed back to the
1134 * completion handler when the asynchronous connect completes.
1136 * This class has all the information necessary for the
1137 * completion handler to uniquiely identify the completion of the
1138 * asynchronous connect.
1140 class ACE_Export ACE_WIN32_Asynch_Connect_Result
: public virtual ACE_Asynch_Connect_Result_Impl
,
1141 public ACE_WIN32_Asynch_Result
1143 /// Factory classes will have special permissions.
1144 friend class ACE_WIN32_Asynch_Connect
;
1146 /// The Proactor constructs the Result class for faking results.
1147 friend class ACE_WIN32_Proactor
;
1151 /// I/O handle for the connection.
1152 ACE_HANDLE
connect_handle (void) const;
1154 // = Base class operations. These operations are here to kill some
1155 // warnings. These methods call the base class methods.
1157 /// Number of bytes transferred by the operation.
1158 size_t bytes_transferred (void) const;
1160 /// ACT associated with the operation.
1161 const void *act (void) const;
1163 /// Did the operation succeed?
1164 int success (void) const;
1167 * Returns the ACT associated with the handle when it was
1168 * registered with the I/O completion port. This ACT is not the
1169 * same as the ACT associated with the asynchronous operation.
1171 const void *completion_key (void) const;
1173 /// Error value if the operation fail.
1174 u_long
error (void) const;
1176 /// Event associated with the OVERLAPPED structure.
1177 ACE_HANDLE
event (void) const;
1179 /// This really make sense only when doing file I/O.
1180 u_long
offset (void) const;
1182 /// Offset_high associated with the OVERLAPPED structure.
1183 u_long
offset_high (void) const;
1185 /// The priority of the asynchronous operation. Currently, this is
1186 /// not supported on Win32.
1187 int priority (void) const;
1189 /// No-op. Returns 0.
1190 int signal_number (void) const;
1192 /// Post this object to the Proactor's completion port.
1193 int post_completion (ACE_Proactor_Impl
*proactor
);
1196 /// Constructor is protected since creation is limited to
1197 /// ACE_Asynch_Connect factory.
1198 ACE_WIN32_Asynch_Connect_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1199 ACE_HANDLE connect_handle
,
1205 /// ACE_Proactor will call this method when the accept completes.
1206 virtual void complete (size_t bytes_transferred
,
1208 const void *completion_key
,
1212 virtual ~ACE_WIN32_Asynch_Connect_Result (void);
1214 /// Set the I/O handle for the new connection.
1215 void connect_handle (ACE_HANDLE handle
);
1217 ACE_HANDLE connect_handle_
;
1222 * @class ACE_WIN32_Asynch_Connect
1224 class ACE_Export ACE_WIN32_Asynch_Connect
:
1225 public virtual ACE_Asynch_Connect_Impl
,
1226 public ACE_WIN32_Asynch_Operation
,
1227 public ACE_Event_Handler
1232 ACE_WIN32_Asynch_Connect (ACE_WIN32_Proactor
* win32_proactor
);
1235 virtual ~ACE_WIN32_Asynch_Connect (void);
1238 * This open belongs to ACE_WIN32_Asynch_Operation. We forward
1239 * this call to that method. We have put this here to avoid the
1240 * compiler warnings.
1242 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1244 const void *completion_key
,
1245 ACE_Proactor
*proactor
= 0);
1248 * Start an asynchronous connect.
1250 * @param connect_handle Handle to use for the connect. If the value
1251 * ACE_INVALID_HANDLE, a new handle will be created.
1256 int connect (ACE_HANDLE connect_handle
,
1257 const ACE_Addr
&remote_sap
,
1258 const ACE_Addr
&local_sap
,
1262 int signal_number
= 0);
1265 * Cancel all pending pseudo-asynchronus requests
1266 * Behavior as usual AIO request
1271 * Close performs cancellation of all pending requests
1272 * and close the connect handle
1276 /// Virtual from ACE_Event_Handler
1277 ACE_HANDLE
get_handle (void) const;
1279 /// Virtual from ACE_Event_Handler
1280 void set_handle (ACE_HANDLE handle
);
1282 /// Virtual from ACE_Event_Handler
1283 int handle_input ( ACE_HANDLE handle
);
1284 int handle_output ( ACE_HANDLE handle
);
1285 int handle_exception ( ACE_HANDLE handle
);
1287 /// Virtual from ACE_Event_Handler
1288 int handle_close (ACE_HANDLE handle
, ACE_Reactor_Mask close_mask
) ;
1290 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
1291 // methods are defined here to avoid dominace warnings. They route
1292 // the call to the ACE_WIN32_Asynch_Operation base class.
1293 /// Return the underlying proactor.
1294 ACE_Proactor
* proactor (void) const;
1297 int connect_i (ACE_WIN32_Asynch_Connect_Result
*result
,
1298 const ACE_Addr
&remote_sap
,
1299 const ACE_Addr
&local_sap
,
1302 int post_result (ACE_WIN32_Asynch_Connect_Result
*result
, bool flg_post
);
1304 /// Cancel uncompleted connect operations.
1306 * @param flg_notify Indicates whether or not to send notification about
1307 * canceled connect operations. If false, don't send
1308 * notifications. If true, notify user about canceled
1310 * According WIN32 standards we should receive
1311 * notifications on canceled AIO requests.
1313 * @param set Receives the set of I/O handles on which asynchronous
1314 * connect requests were canceled as a result of this
1315 * method. The contents of @a set are completely
1318 int cancel_uncompleted (bool flg_notify
, ACE_Handle_Set
&set
);
1320 /// true - Connect is registered in ACE_Asynch_Pseudo_Task
1321 /// false - Accept is deregisted in ACE_Asynch_Pseudo_Task
1324 typedef ACE_Map_Manager
<ACE_HANDLE
, ACE_WIN32_Asynch_Connect_Result
*, ACE_SYNCH_NULL_MUTEX
>
1327 /// Map of Result pointers that correspond to all the <accept>'s
1329 MAP_MANAGER result_map_
;
1331 /// The lock to protect the result map which is shared. The queue
1332 /// is updated by main thread in the register function call and
1333 /// through the auxillary thread in the asynch pseudo task.
1334 ACE_SYNCH_MUTEX lock_
;
1338 * @class ACE_WIN32_Asynch_Transmit_File_Result
1340 * @brief This class implements ACE_Asynch_Transmit_File::Result for
1343 * This class has all the information necessary for the
1344 * @a handler to uniquiely identify the completion of the
1345 * asynchronous transmit file.
1347 class ACE_Export ACE_WIN32_Asynch_Transmit_File_Result
: public virtual ACE_Asynch_Transmit_File_Result_Impl
,
1348 public ACE_WIN32_Asynch_Result
1350 /// Factory class will have special permission.
1351 friend class ACE_WIN32_Asynch_Transmit_File
;
1353 /// Proactor class has special permission.
1354 friend class ACE_WIN32_Proactor
;
1357 /// Socket used for transmitting the file.
1358 ACE_HANDLE
socket (void) const;
1360 /// File from which the data is read.
1361 ACE_HANDLE
file (void) const;
1363 /// Header and trailer data associated with this transmit file.
1364 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer (void) const;
1366 /// The number of bytes which were requested at the start of the
1367 /// asynchronous transmit file.
1368 size_t bytes_to_write (void) const;
1370 /// Number of bytes per send requested at the start of the transmit
1372 size_t bytes_per_send (void) const;
1374 /// Flags which were passed into transmit file.
1375 u_long
flags (void) const;
1377 // Base class operations. These operations are here to kill some
1378 // warnings. These methods call the base class methods.
1380 /// Number of bytes transferred by the operation.
1381 size_t bytes_transferred (void) const;
1383 /// ACT associated with the operation.
1384 const void *act (void) const;
1386 /// Did the operation succeed?
1387 int success (void) const;
1390 * This returns the ACT associated with the handle when it was
1391 * registered with the I/O completion port. This ACT is not the
1392 * same as the ACT associated with the asynchronous operation.
1394 const void *completion_key (void) const;
1396 /// Error value if the operation fail.
1397 u_long
error (void) const;
1399 /// Event associated with the OVERLAPPED structure.
1400 ACE_HANDLE
event (void) const;
1402 /// This really make sense only when doing file I/O.
1403 u_long
offset (void) const;
1405 /// Offset_high associated with the OVERLAPPED structure.
1406 u_long
offset_high (void) const;
1408 /// The priority of the asynchronous operation. Currently, this is
1409 /// not supported on Win32.
1410 int priority (void) const;
1412 /// No-op. Returns 0.
1413 int signal_number (void) const;
1415 /// Post @c this to the Proactor's completion port.
1416 int post_completion (ACE_Proactor_Impl
*proactor
);
1419 /// Constructor is protected since creation is limited to
1420 /// ACE_Asynch_Transmit_File factory.
1421 ACE_WIN32_Asynch_Transmit_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1424 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer
,
1425 size_t bytes_to_write
,
1428 size_t bytes_per_send
,
1433 int signal_number
= 0);
1435 /// Proactor will call this method when the write completes.
1436 virtual void complete (size_t bytes_transferred
,
1438 const void *completion_key
,
1442 virtual ~ACE_WIN32_Asynch_Transmit_File_Result (void);
1444 /// Network I/O handle.
1447 /// File I/O handle.
1450 /// Header and trailer data associated with this transmit file.
1451 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer_
;
1453 /// The number of bytes which were requested at the start of the
1454 /// asynchronous transmit file.
1455 size_t bytes_to_write_
;
1457 /// Number of bytes per send requested at the start of the transmit
1459 size_t bytes_per_send_
;
1461 /// Flags which were passed into transmit file.
1466 * @class ACE_WIN32_Asynch_Transmit_File
1468 * @brief This class is a factory for starting off asynchronous
1469 * transmit files on a stream.
1471 * Once <open> is called, multiple asynchronous <transmit_file>s
1472 * can started using this class. A
1473 * ACE_Asynch_Transmit_File::Result will be passed back to the
1474 * @a handler when the asynchronous transmit file completes
1475 * through the <ACE_Handler::handle_transmit_file> callback.
1477 * The transmit_file function transmits file data over a
1478 * connected network connection. The function uses the operating
1479 * system's cache manager to retrieve the file data. This
1480 * function provides high-performance file data transfer over
1481 * network connections. This function would be of great use in
1482 * a Web Server, Image Server, etc.
1484 class ACE_Export ACE_WIN32_Asynch_Transmit_File
: public virtual ACE_Asynch_Transmit_File_Impl
,
1485 public ACE_WIN32_Asynch_Operation
1489 ACE_WIN32_Asynch_Transmit_File (ACE_WIN32_Proactor
*win32_proactor
);
1492 * This starts off an asynchronous transmit file. The <file> is a
1493 * handle to an open file. <header_and_trailer> is a pointer to a
1494 * data structure that contains pointers to data to send before and
1495 * after the file data is sent. Set this parameter to 0 if you only
1496 * want to transmit the file data. Upto @a bytes_to_write will be
1497 * written to the <socket>. If you want to send the entire file,
1498 * let @a bytes_to_write = 0. @a bytes_per_send is the size of each
1499 * block of data sent per send operation. Please read the Win32
1500 * documentation on what the flags should be.
1502 int transmit_file (ACE_HANDLE file
,
1503 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer
,
1504 size_t bytes_to_write
,
1507 size_t bytes_per_send
,
1511 int signal_number
= 0);
1514 ~ACE_WIN32_Asynch_Transmit_File (void);
1516 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1517 // methods are defined here to avoid VC++ warnings. They route the
1518 // call to the ACE_WIN32_Asynch_Operation base class.
1521 * Initializes the factory with information which will be used with
1522 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1523 * <ACE_Handler::handle> will be called on the @a handler to get the
1526 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1528 const void *completion_key
,
1529 ACE_Proactor
*proactor
);
1532 * This cancels all pending accepts operations that were issued by
1533 * the calling thread. The function does not cancel asynchronous
1534 * operations issued by other threads.
1538 /// Return the underlying proactor.
1539 ACE_Proactor
* proactor (void) const;
1543 * @class ACE_WIN32_Asynch_Read_Dgram_Result
1545 * @brief This class provides concrete implementation for
1546 * ACE_Asynch_Read_Dgram::Result class.
1548 class ACE_Export ACE_WIN32_Asynch_Read_Dgram_Result
: public virtual ACE_Asynch_Read_Dgram_Result_Impl
,
1549 public ACE_WIN32_Asynch_Result
1551 /// Factory class will have special permissions.
1552 friend class ACE_WIN32_Asynch_Read_Dgram
;
1554 /// Proactor class has special permission.
1555 friend class ACE_WIN32_Proactor
;
1558 /// The number of bytes which were requested at the start of the
1559 /// asynchronous read.
1560 size_t bytes_to_read (void) const;
1562 /// Message block which contains the read data
1563 ACE_Message_Block
*message_block (void) const;
1565 /// The address of where the packet came from
1566 int remote_address (ACE_Addr
& addr
) const;
1568 sockaddr
*saddr () const;
1570 /// The flags used in the read
1571 int flags (void) const;
1573 /// I/O handle used for reading.
1574 ACE_HANDLE
handle (void) const;
1576 // Base class operations. These operations are here to kill
1577 // dominance warnings. These methods call the base class methods.
1579 /// Number of bytes transferred by the operation.
1580 size_t bytes_transferred (void) const;
1582 /// ACT associated with the operation.
1583 const void *act (void) const;
1585 /// Did the operation succeed?
1586 int success (void) const;
1589 * This returns the ACT associated with the handle when it was
1590 * registered with the I/O completion port. This ACT is not the
1591 * same as the ACT associated with the asynchronous operation.
1593 const void *completion_key (void) const;
1595 /// Error value if the operation fail.
1596 u_long
error (void) const;
1598 /// Event associated with the OVERLAPPED structure.
1599 ACE_HANDLE
event (void) const;
1601 /// This really make sense only when doing file I/O.
1602 u_long
offset (void) const;
1604 /// Offset_high associated with the OVERLAPPED structure.
1605 u_long
offset_high (void) const;
1607 /// The priority of the asynchronous operation. Currently, this is
1608 /// not supported on Win32.
1609 int priority (void) const;
1611 /// No-op. Returns 0.
1612 int signal_number (void) const;
1614 /// Post @c this to the Proactor's completion port.
1615 int post_completion (ACE_Proactor_Impl
*proactor
);
1618 /// Constructor is protected since creation is limited to
1619 /// ACE_Asynch_Read_Dgram factory.
1620 ACE_WIN32_Asynch_Read_Dgram_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1622 ACE_Message_Block
*message_block
,
1623 size_t bytes_to_read
,
1625 int protocol_family
,
1629 int signal_number
= 0);
1631 /// Proactor will call this method when the read completes.
1632 virtual void complete (size_t bytes_transferred
,
1634 const void *completion_key
,
1638 virtual ~ACE_WIN32_Asynch_Read_Dgram_Result (void);
1640 /// Bytes requested when the asynchronous read was initiated.
1641 size_t bytes_to_read_
;
1643 /// Message block for reading the data into.
1644 ACE_Message_Block
*message_block_
;
1646 /// The address of where the packet came from
1647 ACE_Addr
*remote_address_
;
1651 /// The flags used in the read
1654 /// I/O handle used for reading.
1659 * @class ACE_WIN32_Asynch_Read_Dgram
1661 * @brief This class is a factory for starting off asynchronous reads
1664 * Once <open> is called, multiple asynchronous <read>s can be
1665 * started using this class. An ACE_Asynch_Read_Dgram::Result
1666 * will be passed back to the @a handler when the asynchronous
1667 * reads completes through the <ACE_Handler::handle_read_stream>
1670 class ACE_Export ACE_WIN32_Asynch_Read_Dgram
: public virtual ACE_Asynch_Read_Dgram_Impl
,
1671 public ACE_WIN32_Asynch_Operation
1675 ACE_WIN32_Asynch_Read_Dgram (ACE_WIN32_Proactor
*win32_proactor
);
1678 virtual ~ACE_WIN32_Asynch_Read_Dgram (void);
1680 /** This starts off an asynchronous read. Upto
1681 * <message_block->total_size()> will be read and stored in the
1682 * @a message_block. @a message_block's <wr_ptr> will be updated to reflect
1683 * the added bytes if the read operation is successfully completed.
1684 * Return code of 1 means immediate success and <number_of_bytes_recvd>
1685 * will contain number of bytes read. The <ACE_Handler::handle_read_dgram>
1686 * method will still be called. Return code of 0 means the IO will
1687 * complete proactively. Return code of -1 means there was an error, use
1688 * errno to get the error code.
1690 * Scatter/gather is supported on WIN32 by using the <message_block->cont()>
1691 * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto
1692 * <message_block->size()> bytes will be read into each <message block> for
1693 * a total of <message_block->total_size()> bytes. All @a message_block's
1694 * <wr_ptr>'s will be updated to reflect the added bytes for each
1697 virtual ssize_t
recv (ACE_Message_Block
*message_block
,
1698 size_t &number_of_bytes_recvd
,
1700 int protocol_family
,
1705 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1706 // methods are defined here to avoid VC++ warnings. They route the
1707 // call to the ACE_WIN32_Asynch_Operation base class.
1710 * Initializes the factory with information which will be used with
1711 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1712 * <ACE_Handler::handle> will be called on the @a handler to get the
1715 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1717 const void *completion_key
,
1718 ACE_Proactor
*proactor
);
1721 * This cancels all pending accepts operations that were issued by
1722 * the calling thread. The function does not cancel asynchronous
1723 * operations issued by other threads.
1727 /// Return the underlying proactor.
1728 ACE_Proactor
* proactor (void) const;
1731 /// Do-nothing constructor.
1732 ACE_WIN32_Asynch_Read_Dgram (void);
1736 * @class ACE_WIN32_Asynch_Write_Dgram_Result
1738 * @brief This class provides concrete implementation for
1739 * ACE_Asynch_Write_Dgram::Result class.
1741 class ACE_Export ACE_WIN32_Asynch_Write_Dgram_Result
: public virtual ACE_Asynch_Write_Dgram_Result_Impl
,
1742 public ACE_WIN32_Asynch_Result
1744 /// Factory class willl have special permissions.
1745 friend class ACE_WIN32_Asynch_Write_Dgram
;
1747 /// Proactor class has special permission.
1748 friend class ACE_WIN32_Proactor
;
1751 /// The number of bytes which were requested at the start of the
1752 /// asynchronous write.
1753 size_t bytes_to_write (void) const;
1755 /// Message block which contains the sent data
1756 ACE_Message_Block
*message_block (void) const;
1758 /// The flags using in the write
1759 int flags (void) const;
1761 /// I/O handle used for writing.
1762 ACE_HANDLE
handle (void) const;
1764 // = Base class operations. These operations are here to kill some
1765 // warnings. These methods call the base class methods.
1767 /// Number of bytes transferred by the operation.
1768 size_t bytes_transferred (void) const;
1770 /// ACT associated with the operation.
1771 const void *act (void) const;
1773 /// Did the operation succeed?
1774 int success (void) const;
1777 * This returns the ACT associated with the handle when it was
1778 * registered with the I/O completion port. This ACT is not the
1779 * same as the ACT associated with the asynchronous operation.
1781 const void *completion_key (void) const;
1783 /// Error value if the operation fail.
1784 u_long
error (void) const;
1786 /// Event associated with the OVERLAPPED structure.
1787 ACE_HANDLE
event (void) const;
1789 /// This really make sense only when doing file I/O.
1790 u_long
offset (void) const;
1792 /// Offset_high associated with the OVERLAPPED structure.
1793 u_long
offset_high (void) const;
1795 /// The priority of the asynchronous operation. Currently, this is
1796 /// not supported on Win32.
1797 int priority (void) const;
1799 /// No-op. Returns 0.
1800 int signal_number (void) const;
1802 /// Post @c this to the Proactor's completion port.
1803 int post_completion (ACE_Proactor_Impl
*proactor
);
1806 /// Constructor is protected since creation is limited to
1807 /// ACE_Asynch_Write_Stream factory.
1808 ACE_WIN32_Asynch_Write_Dgram_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1810 ACE_Message_Block
*message_block
,
1811 size_t bytes_to_write
,
1816 int signal_number
= 0);
1818 /// ACE_Proactor will call this method when the write completes.
1819 virtual void complete (size_t bytes_transferred
,
1821 const void *completion_key
,
1825 virtual ~ACE_WIN32_Asynch_Write_Dgram_Result (void);
1827 /// The number of bytes which were requested at the start of the
1828 /// asynchronous write.
1829 size_t bytes_to_write_
;
1831 /// Message block used for the send.
1832 ACE_Message_Block
*message_block_
;
1834 /// The flags using in the write
1837 /// I/O handle used for writing.
1842 * @class ACE_WIN32_Asynch_Write_Dgram
1844 * @brief This class is a factory for starting off asynchronous writes
1847 * Once <open> is called, multiple asynchronous <writes>s can
1848 * started using this class. A ACE_Asynch_Write_Stream::Result
1849 * will be passed back to the @a handler when the asynchronous
1850 * write completes through the
1851 * <ACE_Handler::handle_write_stream> callback.
1853 class ACE_Export ACE_WIN32_Asynch_Write_Dgram
: public virtual ACE_Asynch_Write_Dgram_Impl
,
1854 public ACE_WIN32_Asynch_Operation
1858 ACE_WIN32_Asynch_Write_Dgram (ACE_WIN32_Proactor
*win32_proactor
);
1861 virtual ~ACE_WIN32_Asynch_Write_Dgram (void);
1863 /** This starts off an asynchronous send. Upto
1864 * <message_block->total_length()> will be sent. @a message_block's
1865 * <rd_ptr> will be updated to reflect the sent bytes if the send operation
1866 * is successfully completed.
1867 * Return code of 1 means immediate success and <number_of_bytes_sent>
1868 * is updated to number of bytes sent. The <ACE_Handler::handle_write_dgram>
1869 * method will still be called. Return code of 0 means the IO will
1870 * complete proactively. Return code of -1 means there was an error, use
1871 * errno to get the error code.
1873 * Scatter/gather is supported on WIN32 by using the <message_block->cont()>
1874 * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto
1875 * <message_block->length()> bytes will be sent from each <message block>
1876 * for a total of <message_block->total_length()> bytes. All
1877 * @a message_block's <rd_ptr>'s will be updated to reflect the bytes sent
1878 * from each @a message_block.
1880 virtual ssize_t
send (ACE_Message_Block
*message_block
,
1881 size_t &number_of_bytes_sent
,
1883 const ACE_Addr
&addr
,
1888 // = Methods belonging to <ACE_WIN32_Asynch_Operation> base class.
1890 // These methods are defined here to avoid VC++ warnings. They route
1891 // the call to the <ACE_WIN32_Asynch_Operation> base class.
1894 * Initializes the factory with information which will be used with
1895 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1896 * <ACE_Handler::handle> will be called on the @a handler to get the
1899 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1901 const void *completion_key
,
1902 ACE_Proactor
*proactor
);
1905 * This cancels all pending accepts operations that were issued by
1906 * the calling thread. The function does not cancel asynchronous
1907 * operations issued by other threads.
1911 /// Return the underlying proactor.
1912 ACE_Proactor
* proactor (void) const;
1915 /// Do-nothing constructor.
1916 ACE_WIN32_Asynch_Write_Dgram (void);
1919 ACE_END_VERSIONED_NAMESPACE_DECL
1921 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO && ACE_HAS_WINSOCK2 */
1922 #include /**/ "ace/post.h"
1923 #endif /* ACE_WIN32_ASYNCH_IO_H */