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 () const;
72 /// ACT associated with the operation.
73 const void *act () const;
75 /// Did the operation succeed?
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 () const;
85 /// Error value if the operation fail.
86 u_long
error () const;
88 /// Event associated with the OVERLAPPED structure.
89 ACE_HANDLE
event () const;
91 /// This really make sense only when doing file I/O.
92 u_long
offset () const;
94 /// Offset_high associated with the OVERLAPPED structure.
95 u_long
offset_high () const;
97 /// The priority of the asynchronous operation. Currently, this is
98 /// not supported on Win32.
99 int priority () const;
102 int signal_number () 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 ();
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 () const;
179 ACE_WIN32_Asynch_Operation (ACE_WIN32_Proactor
*win32_proactor
);
182 virtual ~ACE_WIN32_Asynch_Operation ();
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 () const;
217 /// Message block which contains the read data.
218 ACE_Message_Block
&message_block () const;
220 /// I/O handle used for reading.
221 ACE_HANDLE
handle () 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 () const;
229 /// ACT associated with the operation.
230 const void *act () const;
232 /// Did the operation succeed?
233 int success () 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 () const;
242 /// Error value if the operation fail.
243 u_long
error () const;
245 /// Event associated with the OVERLAPPED structure.
246 ACE_HANDLE
event () const;
248 /// This really make sense only when doing file I/O.
249 u_long
offset () const;
251 /// Offset_high associated with the OVERLAPPED structure.
252 u_long
offset_high () const;
254 /// The priority of the asynchronous operation. Currently, this is
255 /// not supported on Win32.
256 int priority () const;
258 /// No-op. Returns 0.
259 int signal_number () 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 () 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 ();
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
319 ACE_WIN32_Asynch_Read_Stream (ACE_WIN32_Proactor
*win32_proactor
);
321 /// This starts off an asynchronous read. Upto @a bytes_to_read will
322 /// be read and stored in the @a message_block.
323 int read (ACE_Message_Block
&message_block
,
324 size_t bytes_to_read
,
327 int signal_number
= 0);
330 * Same as above but with scatter support, through chaining of composite
331 * message blocks using the continuation field.
333 int readv (ACE_Message_Block
&message_block
,
334 size_t bytes_to_read
,
337 int signal_number
= 0);
340 virtual ~ACE_WIN32_Asynch_Read_Stream ();
342 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
343 // methods are defined here to avoid VC++ warnings. They route the
344 // call to the ACE_WIN32_Asynch_Operation base class.
347 * Initializes the factory with information which will be used with
348 * each asynchronous call. If (@a handle == ACE_INVALID_HANDLE),
349 * ACE_Handler::handle() will be called on the @a handler to get the
352 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
354 const void *completion_key
,
355 ACE_Proactor
*proactor
);
358 * This cancels all pending accepts operations that were issued by
359 * the calling thread. The function does not cancel asynchronous
360 * operations issued by other threads.
364 /// Return the underlying proactor.
365 ACE_Proactor
* proactor () const;
368 /// This is the method which does the real work and is there so that
369 /// the ACE_Asynch_Read_File class can use it too.
370 int shared_read (ACE_WIN32_Asynch_Read_Stream_Result
*result
);
374 * @class ACE_WIN32_Asynch_Write_Stream_Result
376 * @brief This class provides concrete implementation for
377 * ACE_Asynch_Write_Stream::Result class.
379 class ACE_Export ACE_WIN32_Asynch_Write_Stream_Result
: public virtual ACE_Asynch_Write_Stream_Result_Impl
,
380 public ACE_WIN32_Asynch_Result
382 /// Factory class willl have special permissions.
383 friend class ACE_WIN32_Asynch_Write_Stream
;
385 /// Proactor class has special permission.
386 friend class ACE_WIN32_Proactor
;
389 /// The number of bytes which were requested at the start of the
390 /// asynchronous write.
391 size_t bytes_to_write () const;
393 /// Message block that contains the data to be written.
394 ACE_Message_Block
&message_block () const;
396 /// I/O handle used for writing.
397 ACE_HANDLE
handle () const;
399 // = Base class operations. These operations are here to kill some
400 // warnings. These methods call the base class methods.
402 /// Number of bytes transferred by the operation.
403 size_t bytes_transferred () const;
405 /// ACT associated with the operation.
406 const void *act () const;
408 /// Did the operation succeed?
409 int success () const;
412 * This returns the ACT associated with the handle when it was
413 * registered with the I/O completion port. This ACT is not the
414 * same as the ACT associated with the asynchronous operation.
416 const void *completion_key () const;
418 /// Error value if the operation fail.
419 u_long
error () const;
421 /// Event associated with the OVERLAPPED structure.
422 ACE_HANDLE
event () const;
424 /// This really make sense only when doing file I/O.
425 u_long
offset () const;
427 /// Offset_high associated with the OVERLAPPED structure.
428 u_long
offset_high () const;
430 /// The priority of the asynchronous operation. Currently, this is
431 /// not supported on Win32.
432 int priority () const;
434 /// No-op. Returns 0.
435 int signal_number () const;
437 /// Post @c this to the Proactor's completion port.
438 int post_completion (ACE_Proactor_Impl
*proactor
);
440 /// Accessor for the gather write flag
441 int gather_enabled () const;
444 /// Constructor is protected since creation is limited to
445 /// ACE_Asynch_Write_Stream factory.
446 ACE_WIN32_Asynch_Write_Stream_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
448 ACE_Message_Block
&message_block
,
449 size_t bytes_to_write
,
453 int signal_number
= 0,
454 int gather_enabled
= 0);
456 /// ACE_Proactor will call this method when the write completes.
457 virtual void complete (size_t bytes_transferred
,
459 const void *completion_key
,
463 virtual ~ACE_WIN32_Asynch_Write_Stream_Result ();
465 /// The number of bytes which were requested at the start of the
466 /// asynchronous write.
467 size_t bytes_to_write_
;
469 /// Message block that contains the data to be written.
470 ACE_Message_Block
&message_block_
;
472 /// I/O handle used for writing.
475 /// Flag for gather write
480 * @class ACE_WIN32_Asynch_Write_Stream
482 * @brief This class is a factory for starting off asynchronous writes
485 * Once open() is called, multiple asynchronous <writes>s can
486 * started using this class. A ACE_Asynch_Write_Stream::Result
487 * will be passed back to the @a handler when the asynchronous
488 * write completes through the
489 * ACE_Handler::handle_write_stream() callback.
491 class ACE_Export ACE_WIN32_Asynch_Write_Stream
: public virtual ACE_Asynch_Write_Stream_Impl
,
492 public ACE_WIN32_Asynch_Operation
496 ACE_WIN32_Asynch_Write_Stream (ACE_WIN32_Proactor
*win32_proactor
);
498 /// This starts off an asynchronous write. Upto @a bytes_to_write
499 /// will be written from the @a message_block.
500 int write (ACE_Message_Block
&message_block
,
501 size_t bytes_to_write
,
504 int signal_number
= 0);
507 * Same as above but with gather support, through chaining of composite
508 * message blocks using the continuation field.
510 int writev (ACE_Message_Block
&message_block
,
511 size_t bytes_to_write
,
514 int signal_number
= 0);
517 virtual ~ACE_WIN32_Asynch_Write_Stream ();
519 // = Methods belonging to <ACE_WIN32_Asynch_Operation> base class.
521 // These methods are defined here to avoid VC++ warnings. They route
522 // the call to the <ACE_WIN32_Asynch_Operation> base class.
525 * Initializes the factory with information which will be used with
526 * each asynchronous call. If (@a handle == ACE_INVALID_HANDLE),
527 * ACE_Handler::handle() will be called on the @a handler to get the
530 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
532 const void *completion_key
,
533 ACE_Proactor
*proactor
);
536 * This cancels all pending accepts operations that were issued by
537 * the calling thread. The function does not cancel asynchronous
538 * operations issued by other threads.
542 /// Return the underlying proactor.
543 ACE_Proactor
* proactor () const;
547 * @class ACE_WIN32_Asynch_Read_File_Result
549 * @brief This class provides concrete implementation for
550 * ACE_Asynch_Read_File::Result class.
552 class ACE_Export ACE_WIN32_Asynch_Read_File_Result
: public virtual ACE_Asynch_Read_File_Result_Impl
,
553 public ACE_WIN32_Asynch_Read_Stream_Result
555 /// Factory class will have special permissions.
556 friend class ACE_WIN32_Asynch_Read_File
;
558 /// Proactor class has special permission.
559 friend class ACE_WIN32_Proactor
;
562 // = These methods belong to ACE_WIN32_Asynch_Result class base
563 // class. These operations are here to kill some warnings. These
564 // methods call the base class methods.
566 /// Number of bytes transferred by the operation.
567 size_t bytes_transferred () const;
569 /// ACT associated with the operation.
570 const void *act () const;
572 /// Did the operation succeed?
573 int success () const;
576 * This returns the ACT associated with the handle when it was
577 * registered with the I/O completion port. This ACT is not the
578 * same as the ACT associated with the asynchronous operation.
580 const void *completion_key () const;
582 /// Error value if the operation fail.
583 u_long
error () const;
585 /// Event associated with the OVERLAPPED structure.
586 ACE_HANDLE
event () const;
588 /// This really make sense only when doing file I/O.
589 u_long
offset () const;
591 /// Offset_high associated with the OVERLAPPED structure.
592 u_long
offset_high () const;
594 /// The priority of the asynchronous operation. Currently, this is
595 /// not supported on Win32.
596 int priority () const;
598 /// No-op. Returns 0.
599 int signal_number () const;
601 // The following methods belong to
602 // ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++
603 // dominance warnings. These methods route their call to the
604 // ACE_WIN32_Asynch_Read_Stream_Result base class.
606 /// The number of bytes which were requested at the start of the
607 /// asynchronous read.
608 size_t bytes_to_read () const;
610 /// Message block which contains the read data.
611 ACE_Message_Block
&message_block () const;
613 /// I/O handle used for reading.
614 ACE_HANDLE
handle () const;
616 /// Post @c this to the Proactor's completion port.
617 int post_completion (ACE_Proactor_Impl
*proactor
);
620 /// Constructor is protected since creation is limited to
621 /// ACE_Asynch_Read_File factory.
622 ACE_WIN32_Asynch_Read_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
624 ACE_Message_Block
&message_block
,
625 size_t bytes_to_read
,
631 int signal_number
= 0,
632 int scatter_enabled
= 0);
634 /// ACE_Proactor will call this method when the read completes.
635 virtual void complete (size_t bytes_transferred
,
637 const void *completion_key
,
641 virtual ~ACE_WIN32_Asynch_Read_File_Result ();
645 * @class ACE_WIN32_Asynch_Read_File
647 * @brief This class is a factory for starting off asynchronous reads
650 * Once <open> is called, multiple asynchronous <read>s can
651 * started using this class. A ACE_Asynch_Read_File::Result
652 * will be passed back to the @a handler when the asynchronous
653 * reads completes through the <ACE_Handler::handle_read_file>
656 * This class differs slightly from ACE_Asynch_Read_Stream as it
657 * allows the user to specify an offset for the read.
659 class ACE_Export ACE_WIN32_Asynch_Read_File
: public virtual ACE_Asynch_Read_File_Impl
,
660 public ACE_WIN32_Asynch_Read_Stream
664 ACE_WIN32_Asynch_Read_File (ACE_WIN32_Proactor
*win32_proactor
);
667 * This starts off an asynchronous read. Upto @a bytes_to_read will
668 * be read and stored in the @a message_block. The read will start
669 * at @a offset from the beginning of the file.
671 int read (ACE_Message_Block
&message_block
,
672 size_t bytes_to_read
,
677 int signal_number
= 0);
680 * Same as above but with scatter support, through chaining of
681 * composite message blocks using the continuation field.
682 * @note Each data block payload must be at least the size of a
683 * system memory page and must be aligned on a system memory page
686 int readv (ACE_Message_Block
&message_block
,
687 size_t bytes_to_read
,
692 int signal_number
= 0);
696 virtual ~ACE_WIN32_Asynch_Read_File ();
698 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
699 // methods are defined here to avoid VC++ warnings. They route the
700 // call to the ACE_WIN32_Asynch_Operation base class.
703 * Initializes the factory with information which will be used with
704 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
705 * <ACE_Handler::handle> will be called on the @a handler to get the
708 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
710 const void *completion_key
,
711 ACE_Proactor
*proactor
);
714 * This cancels all pending accepts operations that were issued by
715 * the calling thread. The function does not cancel asynchronous
716 * operations issued by other threads.
720 /// Return the underlying proactor.
721 ACE_Proactor
* proactor () const;
725 * This method belongs to ACE_WIN32_Asynch_Read_Stream. It is here
726 * to avoid the compiler warnings. We forward this call to the
727 * ACE_WIN32_Asynch_Read_Stream class.
729 int read (ACE_Message_Block
&message_block
,
730 size_t bytes_to_read
,
733 int signal_number
= 0);
736 * Same as above but with scatter support, through chaining of composite
737 * message blocks using the continuation field.
739 int readv (ACE_Message_Block
&message_block
,
740 size_t bytes_to_read
,
743 int signal_number
= 0);
747 * @class ACE_WIN32_Asynch_Write_File_Result
749 * @brief This class provides implementation for
750 * ACE_Asynch_Write_File_Result for WIN32 platforms.
752 * This class has all the information necessary for the
753 * @a handler to uniquiely identify the completion of the
754 * asynchronous write.
756 * This class differs slightly from
757 * ACE_Asynch_Write_Stream::Result as it calls back
758 * <ACE_Handler::handle_write_file> on the @a handler instead
759 * of <ACE_Handler::handle_write_stream>. No additional state
760 * is required by this class as ACE_Asynch_Result can store
763 class ACE_Export ACE_WIN32_Asynch_Write_File_Result
: public virtual ACE_Asynch_Write_File_Result_Impl
,
764 public ACE_WIN32_Asynch_Write_Stream_Result
766 /// Factory class will have special permission.
767 friend class ACE_WIN32_Asynch_Write_File
;
769 /// Proactor class has special permission.
770 friend class ACE_WIN32_Proactor
;
773 // = Base class operations. These operations are here to kill some
774 // warnings. These methods call the base class methods.
776 /// Number of bytes transferred by the operation.
777 size_t bytes_transferred () const;
779 /// ACT associated with the operation.
780 const void *act () const;
782 /// Did the operation succeed?
783 int success () const;
786 * This returns the ACT associated with the handle when it was
787 * registered with the I/O completion port. This ACT is not the
788 * same as the ACT associated with the asynchronous operation.
790 const void *completion_key () const;
792 /// Error value if the operation fail.
793 u_long
error () const;
795 /// Event associated with the OVERLAPPED structure.
796 ACE_HANDLE
event () const;
798 /// This really make sense only when doing file I/O.
799 u_long
offset () const;
801 /// Offset_high associated with the OVERLAPPED structure.
802 u_long
offset_high () const;
804 /// The priority of the asynchronous operation. Currently, this is
805 /// not supported on Win32.
806 int priority () const;
808 /// No-op. Returns 0.
809 int signal_number () const;
811 // The following methods belong to
812 // ACE_WIN32_Asynch_Read_Stream_Result. They are here to avoid VC++
813 // warnings. These methods route their call to the
814 // ACE_WIN32_Asynch_Read_Stream_Result base class.
816 /// The number of bytes which were requested at the start of the
817 /// asynchronous write.
818 size_t bytes_to_write () const;
820 /// Message block that contains the data to be written.
821 ACE_Message_Block
&message_block () const;
823 /// I/O handle used for writing.
824 ACE_HANDLE
handle () const;
826 /// Post @c this to the Proactor's completion port.
827 int post_completion (ACE_Proactor_Impl
*proactor
);
830 /// Constructor is protected since creation is limited to
831 /// ACE_Asynch_Write_File factory.
832 ACE_WIN32_Asynch_Write_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
834 ACE_Message_Block
&message_block
,
835 size_t bytes_to_write
,
841 int signal_number
= 0,
842 int gather_enabled
= 0);
844 /// ACE_Proactor will call this method when the write completes.
845 virtual void complete (size_t bytes_transferred
,
847 const void *completion_key
,
851 virtual ~ACE_WIN32_Asynch_Write_File_Result ();
855 * @class ACE_WIN32_Asynch_Write_File
857 * @brief This class is a factory for starting off asynchronous writes
860 * Once <open> is called, multiple asynchronous <write>s can be
861 * started using this class. A ACE_Asynch_Write_File::Result
862 * will be passed back to the @a handler when the asynchronous
863 * writes completes through the <ACE_Handler::handle_write_file>
866 class ACE_Export ACE_WIN32_Asynch_Write_File
: public virtual ACE_Asynch_Write_File_Impl
,
867 public ACE_WIN32_Asynch_Write_Stream
871 ACE_WIN32_Asynch_Write_File (ACE_WIN32_Proactor
*win32_proactor
);
874 * This starts off an asynchronous write. Upto @a bytes_to_write
875 * will be write and stored in the @a message_block. The write will
876 * start at @a offset from the beginning of the file.
878 int write (ACE_Message_Block
&message_block
,
879 size_t bytes_to_write
,
884 int signal_number
= 0);
887 * Same as above but with gather support, through chaining of
888 * composite message blocks using the continuation field.
889 * @note Each data block payload must be at least the size of a
890 * system memory page and must be aligned on a system memory page
893 int writev (ACE_Message_Block
&message_block
,
894 size_t bytes_to_write
,
899 int signal_number
= 0);
902 virtual ~ACE_WIN32_Asynch_Write_File ();
904 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
905 // methods are defined here to avoid VC++ warnings. They route the
906 // call to the ACE_WIN32_Asynch_Operation base class.
909 * Initializes the factory with information which will be used with
910 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
911 * <ACE_Handler::handle> will be called on the @a handler to get the
914 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
916 const void *completion_key
,
917 ACE_Proactor
*proactor
);
920 * This cancels all pending accepts operations that were issued by
921 * the calling thread. The function does not cancel asynchronous
922 * operations issued by other threads.
926 /// Return the underlying proactor.
927 ACE_Proactor
* proactor () const;
931 * This method belongs to ACE_WIN32_Asynch_Write_Stream. It is here
932 * to avoid compiler warnings. This method is forwarded to the
933 * Write_File specific method with 0 offset values.
935 int write (ACE_Message_Block
&message_block
,
936 size_t bytes_to_write
,
939 int signal_number
= 0);
942 * Same as above but with gather support, through chaining of composite
943 * message blocks using the continuation field.
945 int writev (ACE_Message_Block
&message_block
,
946 size_t bytes_to_write
,
949 int signal_number
= 0);
953 * @class ACE_WIN32_Asynch_Accept_Result
955 * @brief This class implements ACE_Asynch_Accept::Result for WIN32
958 * This class has all the information necessary for the
959 * @a handler to uniquiely identify the completion of the
960 * asynchronous accept.
962 class ACE_Export ACE_WIN32_Asynch_Accept_Result
: public virtual ACE_Asynch_Accept_Result_Impl
,
963 public ACE_WIN32_Asynch_Result
965 /// Factory will have special permission.
966 friend class ACE_WIN32_Asynch_Accept
;
968 /// Proactor class has special permission.
969 friend class ACE_WIN32_Proactor
;
972 /// The number of bytes which were requested at the start of the
973 /// asynchronous accept.
974 size_t bytes_to_read () const;
976 /// Message block which contains the read data.
977 ACE_Message_Block
&message_block () const;
979 /// I/O handle used for accepting new connections.
980 ACE_HANDLE
listen_handle () const;
982 /// I/O handle for the new connection.
983 ACE_HANDLE
accept_handle () const;
985 // = Base class operations. These operations are here to kill some
986 // warnings. These methods call the base class methods.
988 /// Number of bytes transferred by the operation.
989 size_t bytes_transferred () const;
991 /// ACT associated with the operation.
992 const void *act () const;
994 /// Did the operation succeed?
995 int success () const;
998 * This returns the ACT associated with the handle when it was
999 * registered with the I/O completion port. This ACT is not the
1000 * same as the ACT associated with the asynchronous operation.
1002 const void *completion_key () const;
1004 /// Error value if the operation fail.
1005 u_long
error () const;
1007 /// Event associated with the OVERLAPPED structure.
1008 ACE_HANDLE
event () const;
1010 /// This really make sense only when doing file I/O.
1011 u_long
offset () const;
1013 /// Offset_high associated with the OVERLAPPED structure.
1014 u_long
offset_high () const;
1016 /// The priority of the asynchronous operation. Currently, this is
1017 /// not supported on Win32.
1018 int priority () const;
1020 /// No-op. Returns 0.
1021 int signal_number () const;
1023 /// Post @c this to the Proactor's completion port.
1024 int post_completion (ACE_Proactor_Impl
*proactor
);
1027 /// Constructor is protected since creation is limited to
1028 /// ACE_Asynch_Accept factory.
1029 ACE_WIN32_Asynch_Accept_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1030 ACE_HANDLE listen_handle
,
1031 ACE_HANDLE accept_handle
,
1032 ACE_Message_Block
&message_block
,
1033 size_t bytes_to_read
,
1037 int signal_number
= 0);
1039 /// ACE_Proactor will call this method when the accept completes.
1040 virtual void complete (size_t bytes_transferred
,
1042 const void *completion_key
,
1046 virtual ~ACE_WIN32_Asynch_Accept_Result ();
1048 /// Bytes requested when the asynchronous read was initiated.
1049 size_t bytes_to_read_
;
1051 /// Message block for reading the data into.
1052 ACE_Message_Block
&message_block_
;
1054 /// I/O handle used for accepting new connections.
1055 ACE_HANDLE listen_handle_
;
1057 /// I/O handle for the new connection.
1058 ACE_HANDLE accept_handle_
;
1062 * @class ACE_WIN32_Asynch_Accept
1064 * @brief This class is a factory for starting off asynchronous accepts
1065 * on a listen handle.
1067 * Once <open> is called, multiple asynchronous <accept>s can
1068 * started using this class. A ACE_Asynch_Accept::Result will
1069 * be passed back to the @a handler when the asynchronous accept
1070 * completes through the <ACE_Handler::handle_accept>
1073 class ACE_Export ACE_WIN32_Asynch_Accept
: public virtual ACE_Asynch_Accept_Impl
,
1074 public ACE_WIN32_Asynch_Operation
1078 ACE_WIN32_Asynch_Accept (ACE_WIN32_Proactor
*win32_proactor
);
1081 * This starts off an asynchronous accept. The asynchronous accept
1082 * call also allows any initial data to be returned to the
1083 * @a handler. Upto @a bytes_to_read will be read and stored in the
1084 * @a message_block. The <accept_handle> will be used for the
1085 * <accept> call. If (<accept_handle> == INVALID_HANDLE), a new
1086 * handle will be created.
1088 * @a message_block must be specified. This is because the address of
1089 * the new connection is placed at the end of this buffer.
1091 int accept (ACE_Message_Block
&message_block
,
1092 size_t bytes_to_read
,
1093 ACE_HANDLE accept_handle
,
1096 int signal_number
= 0,
1097 int addr_family
= AF_INET
);
1100 ~ACE_WIN32_Asynch_Accept ();
1102 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1103 // methods are defined here to avoid VC++ warnings. They route the
1104 // call to the ACE_WIN32_Asynch_Operation base class.
1107 * Initializes the factory with information which will be used with
1108 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1109 * <ACE_Handler::handle> will be called on the @a handler to get the
1112 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1114 const void *completion_key
,
1115 ACE_Proactor
*proactor
);
1118 * This cancels all pending accepts operations that were issued by
1119 * the calling thread. The function does not cancel asynchronous
1120 * operations issued by other threads.
1124 /// Return the underlying proactor.
1125 ACE_Proactor
* proactor () const;
1129 * @class ACE_WIN32_Asynch_Connect_Result
1131 * @brief This is that class which will be passed back to the
1132 * completion handler when the asynchronous connect completes.
1134 * This class has all the information necessary for the
1135 * completion handler to uniquiely identify the completion of the
1136 * asynchronous connect.
1138 class ACE_Export ACE_WIN32_Asynch_Connect_Result
: public virtual ACE_Asynch_Connect_Result_Impl
,
1139 public ACE_WIN32_Asynch_Result
1141 /// Factory classes will have special permissions.
1142 friend class ACE_WIN32_Asynch_Connect
;
1144 /// The Proactor constructs the Result class for faking results.
1145 friend class ACE_WIN32_Proactor
;
1148 /// I/O handle for the connection.
1149 ACE_HANDLE
connect_handle () const;
1151 // = Base class operations. These operations are here to kill some
1152 // warnings. These methods call the base class methods.
1154 /// Number of bytes transferred by the operation.
1155 size_t bytes_transferred () const;
1157 /// ACT associated with the operation.
1158 const void *act () const;
1160 /// Did the operation succeed?
1161 int success () const;
1164 * Returns the ACT associated with the handle when it was
1165 * registered with the I/O completion port. This ACT is not the
1166 * same as the ACT associated with the asynchronous operation.
1168 const void *completion_key () const;
1170 /// Error value if the operation fail.
1171 u_long
error () const;
1173 /// Event associated with the OVERLAPPED structure.
1174 ACE_HANDLE
event () const;
1176 /// This really make sense only when doing file I/O.
1177 u_long
offset () const;
1179 /// Offset_high associated with the OVERLAPPED structure.
1180 u_long
offset_high () const;
1182 /// The priority of the asynchronous operation. Currently, this is
1183 /// not supported on Win32.
1184 int priority () const;
1186 /// No-op. Returns 0.
1187 int signal_number () const;
1189 /// Post this object to the Proactor's completion port.
1190 int post_completion (ACE_Proactor_Impl
*proactor
);
1193 /// Constructor is protected since creation is limited to
1194 /// ACE_Asynch_Connect factory.
1195 ACE_WIN32_Asynch_Connect_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1196 ACE_HANDLE connect_handle
,
1202 /// ACE_Proactor will call this method when the accept completes.
1203 virtual void complete (size_t bytes_transferred
,
1205 const void *completion_key
,
1209 virtual ~ACE_WIN32_Asynch_Connect_Result ();
1211 /// Set the I/O handle for the new connection.
1212 void connect_handle (ACE_HANDLE handle
);
1214 ACE_HANDLE connect_handle_
;
1219 * @class ACE_WIN32_Asynch_Connect
1221 class ACE_Export ACE_WIN32_Asynch_Connect
:
1222 public virtual ACE_Asynch_Connect_Impl
,
1223 public ACE_WIN32_Asynch_Operation
,
1224 public ACE_Event_Handler
1228 ACE_WIN32_Asynch_Connect (ACE_WIN32_Proactor
* win32_proactor
);
1231 virtual ~ACE_WIN32_Asynch_Connect ();
1234 * This open belongs to ACE_WIN32_Asynch_Operation. We forward
1235 * this call to that method. We have put this here to avoid the
1236 * compiler warnings.
1238 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1240 const void *completion_key
,
1241 ACE_Proactor
*proactor
= 0);
1244 * Start an asynchronous connect.
1246 * @param connect_handle Handle to use for the connect. If the value
1247 * ACE_INVALID_HANDLE, a new handle will be created.
1252 int connect (ACE_HANDLE connect_handle
,
1253 const ACE_Addr
&remote_sap
,
1254 const ACE_Addr
&local_sap
,
1258 int signal_number
= 0);
1261 * Cancel all pending pseudo-asynchronus requests
1262 * Behavior as usual AIO request
1267 * Close performs cancellation of all pending requests
1268 * and close the connect handle
1272 /// Virtual from ACE_Event_Handler
1273 ACE_HANDLE
get_handle () const;
1275 /// Virtual from ACE_Event_Handler
1276 void set_handle (ACE_HANDLE handle
);
1278 /// Virtual from ACE_Event_Handler
1279 int handle_input ( ACE_HANDLE handle
);
1280 int handle_output ( ACE_HANDLE handle
);
1281 int handle_exception ( ACE_HANDLE handle
);
1283 /// Virtual from ACE_Event_Handler
1284 int handle_close (ACE_HANDLE handle
, ACE_Reactor_Mask close_mask
) ;
1286 // = Methods belong to ACE_WIN32_Asynch_Operation base class. These
1287 // methods are defined here to avoid dominace warnings. They route
1288 // the call to the ACE_WIN32_Asynch_Operation base class.
1289 /// Return the underlying proactor.
1290 ACE_Proactor
* proactor () const;
1293 int connect_i (ACE_WIN32_Asynch_Connect_Result
*result
,
1294 const ACE_Addr
&remote_sap
,
1295 const ACE_Addr
&local_sap
,
1298 int post_result (ACE_WIN32_Asynch_Connect_Result
*result
, bool flg_post
);
1300 /// Cancel uncompleted connect operations.
1302 * @param flg_notify Indicates whether or not to send notification about
1303 * canceled connect operations. If false, don't send
1304 * notifications. If true, notify user about canceled
1306 * According WIN32 standards we should receive
1307 * notifications on canceled AIO requests.
1309 * @param set Receives the set of I/O handles on which asynchronous
1310 * connect requests were canceled as a result of this
1311 * method. The contents of @a set are completely
1314 int cancel_uncompleted (bool flg_notify
, ACE_Handle_Set
&set
);
1316 /// true - Connect is registered in ACE_Asynch_Pseudo_Task
1317 /// false - Accept is deregisted in ACE_Asynch_Pseudo_Task
1320 typedef ACE_Map_Manager
<ACE_HANDLE
, ACE_WIN32_Asynch_Connect_Result
*, ACE_SYNCH_NULL_MUTEX
>
1323 /// Map of Result pointers that correspond to all the <accept>'s
1325 MAP_MANAGER result_map_
;
1327 /// The lock to protect the result map which is shared. The queue
1328 /// is updated by main thread in the register function call and
1329 /// through the auxillary thread in the asynch pseudo task.
1330 ACE_SYNCH_MUTEX lock_
;
1334 * @class ACE_WIN32_Asynch_Transmit_File_Result
1336 * @brief This class implements ACE_Asynch_Transmit_File::Result for
1339 * This class has all the information necessary for the
1340 * @a handler to uniquiely identify the completion of the
1341 * asynchronous transmit file.
1343 class ACE_Export ACE_WIN32_Asynch_Transmit_File_Result
: public virtual ACE_Asynch_Transmit_File_Result_Impl
,
1344 public ACE_WIN32_Asynch_Result
1346 /// Factory class will have special permission.
1347 friend class ACE_WIN32_Asynch_Transmit_File
;
1349 /// Proactor class has special permission.
1350 friend class ACE_WIN32_Proactor
;
1353 /// Socket used for transmitting the file.
1354 ACE_HANDLE
socket () const;
1356 /// File from which the data is read.
1357 ACE_HANDLE
file () const;
1359 /// Header and trailer data associated with this transmit file.
1360 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer () const;
1362 /// The number of bytes which were requested at the start of the
1363 /// asynchronous transmit file.
1364 size_t bytes_to_write () const;
1366 /// Number of bytes per send requested at the start of the transmit
1368 size_t bytes_per_send () const;
1370 /// Flags which were passed into transmit file.
1371 u_long
flags () const;
1373 // Base class operations. These operations are here to kill some
1374 // warnings. These methods call the base class methods.
1376 /// Number of bytes transferred by the operation.
1377 size_t bytes_transferred () const;
1379 /// ACT associated with the operation.
1380 const void *act () const;
1382 /// Did the operation succeed?
1383 int success () const;
1386 * This returns the ACT associated with the handle when it was
1387 * registered with the I/O completion port. This ACT is not the
1388 * same as the ACT associated with the asynchronous operation.
1390 const void *completion_key () const;
1392 /// Error value if the operation fail.
1393 u_long
error () const;
1395 /// Event associated with the OVERLAPPED structure.
1396 ACE_HANDLE
event () const;
1398 /// This really make sense only when doing file I/O.
1399 u_long
offset () const;
1401 /// Offset_high associated with the OVERLAPPED structure.
1402 u_long
offset_high () const;
1404 /// The priority of the asynchronous operation. Currently, this is
1405 /// not supported on Win32.
1406 int priority () const;
1408 /// No-op. Returns 0.
1409 int signal_number () const;
1411 /// Post @c this to the Proactor's completion port.
1412 int post_completion (ACE_Proactor_Impl
*proactor
);
1415 /// Constructor is protected since creation is limited to
1416 /// ACE_Asynch_Transmit_File factory.
1417 ACE_WIN32_Asynch_Transmit_File_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1420 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer
,
1421 size_t bytes_to_write
,
1424 size_t bytes_per_send
,
1429 int signal_number
= 0);
1431 /// Proactor will call this method when the write completes.
1432 virtual void complete (size_t bytes_transferred
,
1434 const void *completion_key
,
1438 virtual ~ACE_WIN32_Asynch_Transmit_File_Result ();
1440 /// Network I/O handle.
1443 /// File I/O handle.
1446 /// Header and trailer data associated with this transmit file.
1447 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer_
;
1449 /// The number of bytes which were requested at the start of the
1450 /// asynchronous transmit file.
1451 size_t bytes_to_write_
;
1453 /// Number of bytes per send requested at the start of the transmit
1455 size_t bytes_per_send_
;
1457 /// Flags which were passed into transmit file.
1462 * @class ACE_WIN32_Asynch_Transmit_File
1464 * @brief This class is a factory for starting off asynchronous
1465 * transmit files on a stream.
1467 * Once <open> is called, multiple asynchronous <transmit_file>s
1468 * can started using this class. A
1469 * ACE_Asynch_Transmit_File::Result will be passed back to the
1470 * @a handler when the asynchronous transmit file completes
1471 * through the <ACE_Handler::handle_transmit_file> callback.
1473 * The transmit_file function transmits file data over a
1474 * connected network connection. The function uses the operating
1475 * system's cache manager to retrieve the file data. This
1476 * function provides high-performance file data transfer over
1477 * network connections. This function would be of great use in
1478 * a Web Server, Image Server, etc.
1480 class ACE_Export ACE_WIN32_Asynch_Transmit_File
: public virtual ACE_Asynch_Transmit_File_Impl
,
1481 public ACE_WIN32_Asynch_Operation
1485 ACE_WIN32_Asynch_Transmit_File (ACE_WIN32_Proactor
*win32_proactor
);
1488 * This starts off an asynchronous transmit file. The <file> is a
1489 * handle to an open file. <header_and_trailer> is a pointer to a
1490 * data structure that contains pointers to data to send before and
1491 * after the file data is sent. Set this parameter to 0 if you only
1492 * want to transmit the file data. Upto @a bytes_to_write will be
1493 * written to the <socket>. If you want to send the entire file,
1494 * let @a bytes_to_write = 0. @a bytes_per_send is the size of each
1495 * block of data sent per send operation. Please read the Win32
1496 * documentation on what the flags should be.
1498 int transmit_file (ACE_HANDLE file
,
1499 ACE_Asynch_Transmit_File::Header_And_Trailer
*header_and_trailer
,
1500 size_t bytes_to_write
,
1503 size_t bytes_per_send
,
1507 int signal_number
= 0);
1510 ~ACE_WIN32_Asynch_Transmit_File ();
1512 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1513 // methods are defined here to avoid VC++ warnings. They route the
1514 // call to the ACE_WIN32_Asynch_Operation base class.
1517 * Initializes the factory with information which will be used with
1518 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1519 * <ACE_Handler::handle> will be called on the @a handler to get the
1522 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1524 const void *completion_key
,
1525 ACE_Proactor
*proactor
);
1528 * This cancels all pending accepts operations that were issued by
1529 * the calling thread. The function does not cancel asynchronous
1530 * operations issued by other threads.
1534 /// Return the underlying proactor.
1535 ACE_Proactor
* proactor () const;
1539 * @class ACE_WIN32_Asynch_Read_Dgram_Result
1541 * @brief This class provides concrete implementation for
1542 * ACE_Asynch_Read_Dgram::Result class.
1544 class ACE_Export ACE_WIN32_Asynch_Read_Dgram_Result
: public virtual ACE_Asynch_Read_Dgram_Result_Impl
,
1545 public ACE_WIN32_Asynch_Result
1547 /// Factory class will have special permissions.
1548 friend class ACE_WIN32_Asynch_Read_Dgram
;
1550 /// Proactor class has special permission.
1551 friend class ACE_WIN32_Proactor
;
1554 /// The number of bytes which were requested at the start of the
1555 /// asynchronous read.
1556 size_t bytes_to_read () const;
1558 /// Message block which contains the read data
1559 ACE_Message_Block
*message_block () const;
1561 /// The address of where the packet came from
1562 int remote_address (ACE_Addr
& addr
) const;
1564 sockaddr
*saddr () const;
1566 /// The flags used in the read
1569 /// I/O handle used for reading.
1570 ACE_HANDLE
handle () const;
1572 // Base class operations. These operations are here to kill
1573 // dominance warnings. These methods call the base class methods.
1575 /// Number of bytes transferred by the operation.
1576 size_t bytes_transferred () const;
1578 /// ACT associated with the operation.
1579 const void *act () const;
1581 /// Did the operation succeed?
1582 int success () const;
1585 * This returns the ACT associated with the handle when it was
1586 * registered with the I/O completion port. This ACT is not the
1587 * same as the ACT associated with the asynchronous operation.
1589 const void *completion_key () const;
1591 /// Error value if the operation fail.
1592 u_long
error () const;
1594 /// Event associated with the OVERLAPPED structure.
1595 ACE_HANDLE
event () const;
1597 /// This really make sense only when doing file I/O.
1598 u_long
offset () const;
1600 /// Offset_high associated with the OVERLAPPED structure.
1601 u_long
offset_high () const;
1603 /// The priority of the asynchronous operation. Currently, this is
1604 /// not supported on Win32.
1605 int priority () const;
1607 /// No-op. Returns 0.
1608 int signal_number () const;
1610 /// Post @c this to the Proactor's completion port.
1611 int post_completion (ACE_Proactor_Impl
*proactor
);
1614 /// Constructor is protected since creation is limited to
1615 /// ACE_Asynch_Read_Dgram factory.
1616 ACE_WIN32_Asynch_Read_Dgram_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1618 ACE_Message_Block
*message_block
,
1619 size_t bytes_to_read
,
1621 int protocol_family
,
1625 int signal_number
= 0);
1627 /// Proactor will call this method when the read completes.
1628 virtual void complete (size_t bytes_transferred
,
1630 const void *completion_key
,
1634 virtual ~ACE_WIN32_Asynch_Read_Dgram_Result ();
1636 /// Bytes requested when the asynchronous read was initiated.
1637 size_t bytes_to_read_
;
1639 /// Message block for reading the data into.
1640 ACE_Message_Block
*message_block_
;
1642 /// The address of where the packet came from
1643 ACE_Addr
*remote_address_
;
1647 /// The flags used in the read
1650 /// I/O handle used for reading.
1655 * @class ACE_WIN32_Asynch_Read_Dgram
1657 * @brief This class is a factory for starting off asynchronous reads
1660 * Once <open> is called, multiple asynchronous <read>s can be
1661 * started using this class. An ACE_Asynch_Read_Dgram::Result
1662 * will be passed back to the @a handler when the asynchronous
1663 * reads completes through the <ACE_Handler::handle_read_stream>
1666 class ACE_Export ACE_WIN32_Asynch_Read_Dgram
: public virtual ACE_Asynch_Read_Dgram_Impl
,
1667 public ACE_WIN32_Asynch_Operation
1671 ACE_WIN32_Asynch_Read_Dgram (ACE_WIN32_Proactor
*win32_proactor
);
1674 virtual ~ACE_WIN32_Asynch_Read_Dgram ();
1676 /** This starts off an asynchronous read. Upto
1677 * <message_block->total_size()> will be read and stored in the
1678 * @a message_block. @a message_block's <wr_ptr> will be updated to reflect
1679 * the added bytes if the read operation is successfully completed.
1680 * Return code of 1 means immediate success and <number_of_bytes_recvd>
1681 * will contain number of bytes read. The <ACE_Handler::handle_read_dgram>
1682 * method will still be called. Return code of 0 means the IO will
1683 * complete proactively. Return code of -1 means there was an error, use
1684 * errno to get the error code.
1686 * Scatter/gather is supported on WIN32 by using the <message_block->cont()>
1687 * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto
1688 * <message_block->size()> bytes will be read into each <message block> for
1689 * a total of <message_block->total_size()> bytes. All @a message_block's
1690 * <wr_ptr>'s will be updated to reflect the added bytes for each
1693 virtual ssize_t
recv (ACE_Message_Block
*message_block
,
1694 size_t &number_of_bytes_recvd
,
1696 int protocol_family
,
1701 // Methods belong to ACE_WIN32_Asynch_Operation base class. These
1702 // methods are defined here to avoid VC++ warnings. They route the
1703 // call to the ACE_WIN32_Asynch_Operation base class.
1706 * Initializes the factory with information which will be used with
1707 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1708 * <ACE_Handler::handle> will be called on the @a handler to get the
1711 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1713 const void *completion_key
,
1714 ACE_Proactor
*proactor
);
1717 * This cancels all pending accepts operations that were issued by
1718 * the calling thread. The function does not cancel asynchronous
1719 * operations issued by other threads.
1723 /// Return the underlying proactor.
1724 ACE_Proactor
* proactor () const;
1727 /// Do-nothing constructor.
1728 ACE_WIN32_Asynch_Read_Dgram ();
1732 * @class ACE_WIN32_Asynch_Write_Dgram_Result
1734 * @brief This class provides concrete implementation for
1735 * ACE_Asynch_Write_Dgram::Result class.
1737 class ACE_Export ACE_WIN32_Asynch_Write_Dgram_Result
: public virtual ACE_Asynch_Write_Dgram_Result_Impl
,
1738 public ACE_WIN32_Asynch_Result
1740 /// Factory class willl have special permissions.
1741 friend class ACE_WIN32_Asynch_Write_Dgram
;
1743 /// Proactor class has special permission.
1744 friend class ACE_WIN32_Proactor
;
1747 /// The number of bytes which were requested at the start of the
1748 /// asynchronous write.
1749 size_t bytes_to_write () const;
1751 /// Message block which contains the sent data
1752 ACE_Message_Block
*message_block () const;
1754 /// The flags using in the write
1757 /// I/O handle used for writing.
1758 ACE_HANDLE
handle () const;
1760 // = Base class operations. These operations are here to kill some
1761 // warnings. These methods call the base class methods.
1763 /// Number of bytes transferred by the operation.
1764 size_t bytes_transferred () const;
1766 /// ACT associated with the operation.
1767 const void *act () const;
1769 /// Did the operation succeed?
1770 int success () const;
1773 * This returns the ACT associated with the handle when it was
1774 * registered with the I/O completion port. This ACT is not the
1775 * same as the ACT associated with the asynchronous operation.
1777 const void *completion_key () const;
1779 /// Error value if the operation fail.
1780 u_long
error () const;
1782 /// Event associated with the OVERLAPPED structure.
1783 ACE_HANDLE
event () const;
1785 /// This really make sense only when doing file I/O.
1786 u_long
offset () const;
1788 /// Offset_high associated with the OVERLAPPED structure.
1789 u_long
offset_high () const;
1791 /// The priority of the asynchronous operation. Currently, this is
1792 /// not supported on Win32.
1793 int priority () const;
1795 /// No-op. Returns 0.
1796 int signal_number () const;
1798 /// Post @c this to the Proactor's completion port.
1799 int post_completion (ACE_Proactor_Impl
*proactor
);
1802 /// Constructor is protected since creation is limited to
1803 /// ACE_Asynch_Write_Stream factory.
1804 ACE_WIN32_Asynch_Write_Dgram_Result (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1806 ACE_Message_Block
*message_block
,
1807 size_t bytes_to_write
,
1812 int signal_number
= 0);
1814 /// ACE_Proactor will call this method when the write completes.
1815 virtual void complete (size_t bytes_transferred
,
1817 const void *completion_key
,
1821 virtual ~ACE_WIN32_Asynch_Write_Dgram_Result ();
1823 /// The number of bytes which were requested at the start of the
1824 /// asynchronous write.
1825 size_t bytes_to_write_
;
1827 /// Message block used for the send.
1828 ACE_Message_Block
*message_block_
;
1830 /// The flags using in the write
1833 /// I/O handle used for writing.
1838 * @class ACE_WIN32_Asynch_Write_Dgram
1840 * @brief This class is a factory for starting off asynchronous writes
1843 * Once <open> is called, multiple asynchronous <writes>s can
1844 * started using this class. A ACE_Asynch_Write_Stream::Result
1845 * will be passed back to the @a handler when the asynchronous
1846 * write completes through the
1847 * <ACE_Handler::handle_write_stream> callback.
1849 class ACE_Export ACE_WIN32_Asynch_Write_Dgram
: public virtual ACE_Asynch_Write_Dgram_Impl
,
1850 public ACE_WIN32_Asynch_Operation
1854 ACE_WIN32_Asynch_Write_Dgram (ACE_WIN32_Proactor
*win32_proactor
);
1857 virtual ~ACE_WIN32_Asynch_Write_Dgram ();
1859 /** This starts off an asynchronous send. Upto
1860 * <message_block->total_length()> will be sent. @a message_block's
1861 * <rd_ptr> will be updated to reflect the sent bytes if the send operation
1862 * is successfully completed.
1863 * Return code of 1 means immediate success and <number_of_bytes_sent>
1864 * is updated to number of bytes sent. The <ACE_Handler::handle_write_dgram>
1865 * method will still be called. Return code of 0 means the IO will
1866 * complete proactively. Return code of -1 means there was an error, use
1867 * errno to get the error code.
1869 * Scatter/gather is supported on WIN32 by using the <message_block->cont()>
1870 * method. Up to ACE_IOV_MAX @a message_block's are supported. Upto
1871 * <message_block->length()> bytes will be sent from each <message block>
1872 * for a total of <message_block->total_length()> bytes. All
1873 * @a message_block's <rd_ptr>'s will be updated to reflect the bytes sent
1874 * from each @a message_block.
1876 virtual ssize_t
send (ACE_Message_Block
*message_block
,
1877 size_t &number_of_bytes_sent
,
1879 const ACE_Addr
&addr
,
1884 // = Methods belonging to <ACE_WIN32_Asynch_Operation> base class.
1886 // These methods are defined here to avoid VC++ warnings. They route
1887 // the call to the <ACE_WIN32_Asynch_Operation> base class.
1890 * Initializes the factory with information which will be used with
1891 * each asynchronous call. If (<handle> == ACE_INVALID_HANDLE),
1892 * <ACE_Handler::handle> will be called on the @a handler to get the
1895 int open (const ACE_Handler::Proxy_Ptr
&handler_proxy
,
1897 const void *completion_key
,
1898 ACE_Proactor
*proactor
);
1901 * This cancels all pending accepts operations that were issued by
1902 * the calling thread. The function does not cancel asynchronous
1903 * operations issued by other threads.
1907 /// Return the underlying proactor.
1908 ACE_Proactor
* proactor () const;
1911 /// Do-nothing constructor.
1912 ACE_WIN32_Asynch_Write_Dgram ();
1915 ACE_END_VERSIONED_NAMESPACE_DECL
1917 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO && ACE_HAS_WINSOCK2 */
1918 #include /**/ "ace/post.h"
1919 #endif /* ACE_WIN32_ASYNCH_IO_H */