GitHub Actions: Try MSVC builds with /std:c++17 and 20
[ACE_TAO.git] / ACE / ace / Asynch_IO.cpp
blobf50cdc33d310ffd4cf23cf75f3fbd31f6b75824f
1 #include "ace/Asynch_IO.h"
3 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
4 // This only works on platforms with Asynchronous IO
6 #include "ace/Proactor.h"
7 #include "ace/Message_Block.h"
8 #include "ace/INET_Addr.h"
9 #include "ace/Asynch_IO_Impl.h"
10 #include "ace/os_include/os_errno.h"
11 #include "ace/Truncate.h"
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 size_t
16 ACE_Asynch_Result::bytes_transferred (void) const
18 return this->implementation ()->bytes_transferred ();
21 const void *
22 ACE_Asynch_Result::act (void) const
24 return this->implementation ()->act ();
27 int
28 ACE_Asynch_Result::success (void) const
30 return this->implementation ()->success ();
33 const void *
34 ACE_Asynch_Result::completion_key (void) const
36 return this->implementation ()->completion_key ();
39 unsigned long
40 ACE_Asynch_Result::error (void) const
42 return this->implementation ()->error ();
45 ACE_HANDLE
46 ACE_Asynch_Result::event (void) const
48 return this->implementation ()->event ();
51 unsigned long
52 ACE_Asynch_Result::offset (void) const
54 return this->implementation ()->offset ();
57 unsigned long
58 ACE_Asynch_Result::offset_high (void) const
60 return this->implementation ()->offset_high ();
63 int
64 ACE_Asynch_Result::priority (void) const
66 return this->implementation ()->priority ();
69 int
70 ACE_Asynch_Result::signal_number (void) const
72 return this->implementation ()->signal_number ();
75 ACE_Asynch_Result::ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation)
76 : implementation_ (implementation)
80 ACE_Asynch_Result::~ACE_Asynch_Result (void)
82 // Proactor deletes the implementation when the <complete> finishes.
85 ACE_Asynch_Result_Impl *
86 ACE_Asynch_Result::implementation (void) const
88 return this->implementation_;
91 // *********************************************************************
93 int
94 ACE_Asynch_Operation::open (ACE_Handler &handler,
95 ACE_HANDLE handle,
96 const void *completion_key,
97 ACE_Proactor *proactor)
99 return this->implementation ()->open (handler.proxy (),
100 handle,
101 completion_key,
102 proactor);
106 ACE_Asynch_Operation::cancel (void)
108 if (0 == this->implementation ())
110 errno = EFAULT;
111 return -1;
113 return this->implementation ()->cancel ();
116 ACE_Proactor *
117 ACE_Asynch_Operation::proactor (void) const
119 if (0 == this->implementation ())
121 errno = EFAULT;
122 return 0;
124 return this->implementation ()->proactor ();
127 ACE_Asynch_Operation::ACE_Asynch_Operation (void)
131 ACE_Asynch_Operation::~ACE_Asynch_Operation (void)
135 ACE_Proactor *
136 ACE_Asynch_Operation::get_proactor (ACE_Proactor *user_proactor,
137 ACE_Handler &handler) const
139 if (user_proactor == 0)
141 // Grab the singleton proactor if <handler->proactor> is zero
142 user_proactor = handler.proactor ();
143 if (user_proactor == 0)
144 user_proactor = ACE_Proactor::instance ();
147 return user_proactor;
150 // ************************************************************
152 ACE_Asynch_Read_Stream::ACE_Asynch_Read_Stream (void)
153 : implementation_ (0)
157 ACE_Asynch_Read_Stream::~ACE_Asynch_Read_Stream (void)
159 // Delete the implementation.
160 delete this->implementation_;
161 this->implementation_ = 0;
165 ACE_Asynch_Read_Stream::open (ACE_Handler &handler,
166 ACE_HANDLE handle,
167 const void *completion_key,
168 ACE_Proactor *proactor)
170 // Get a proactor for/from the user.
171 proactor = this->get_proactor (proactor, handler);
173 // Now let us get the implementation initialized.
174 if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0)
175 return -1;
177 // Call the <open> method of the base class.
178 return ACE_Asynch_Operation::open (handler,
179 handle,
180 completion_key,
181 proactor);
185 ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block,
186 size_t bytes_to_read,
187 const void *act,
188 int priority,
189 int signal_number)
191 if (0 == this->implementation_)
193 errno = EFAULT;
194 return -1;
196 return this->implementation_->read (message_block,
197 bytes_to_read,
198 act,
199 priority,
200 signal_number);
203 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
205 ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block,
206 size_t bytes_to_read,
207 const void *act,
208 int priority,
209 int signal_number)
211 if (0 == this->implementation_)
213 errno = EFAULT;
214 return -1;
216 return this->implementation_->readv (message_block,
217 bytes_to_read,
218 act,
219 priority,
220 signal_number);
222 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
224 ACE_Asynch_Operation_Impl *
225 ACE_Asynch_Read_Stream::implementation (void) const
227 return this->implementation_;
230 // ************************************************************
232 size_t
233 ACE_Asynch_Read_Stream::Result::bytes_to_read (void) const
235 return this->implementation ()->bytes_to_read ();
238 ACE_Message_Block &
239 ACE_Asynch_Read_Stream::Result::message_block (void) const
241 return this->implementation ()->message_block ();
244 ACE_HANDLE
245 ACE_Asynch_Read_Stream::Result::handle (void) const
247 return this->implementation ()->handle ();
250 ACE_Asynch_Read_Stream::Result::Result (ACE_Asynch_Read_Stream_Result_Impl *implementation)
251 : ACE_Asynch_Result (implementation),
252 implementation_ (implementation)
256 ACE_Asynch_Read_Stream::Result::~Result (void)
258 // Proactor will delete the implementation after <complete> is
259 // finished.
262 ACE_Asynch_Read_Stream_Result_Impl *
263 ACE_Asynch_Read_Stream::Result::implementation (void) const
265 return this->implementation_;
268 // ***************************************************
270 ACE_Asynch_Write_Stream::ACE_Asynch_Write_Stream (void)
271 : implementation_ (0)
275 ACE_Asynch_Write_Stream::~ACE_Asynch_Write_Stream (void)
277 // Delete the implementation.
278 delete this->implementation_;
279 this->implementation_ = 0;
283 ACE_Asynch_Write_Stream::open (ACE_Handler &handler,
284 ACE_HANDLE handle,
285 const void *completion_key,
286 ACE_Proactor *proactor)
288 // Get a proactor for/from the user.
289 proactor = this->get_proactor (proactor, handler);
291 // Now let us get the implementation initialized.
292 if ((this->implementation_ = proactor->create_asynch_write_stream ()) == 0)
293 return -1;
295 // Call the <open> method of the base class.
296 return ACE_Asynch_Operation::open (handler,
297 handle,
298 completion_key,
299 proactor);
303 ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block,
304 size_t bytes_to_write,
305 const void *act,
306 int priority,
307 int signal_number)
309 if (0 == this->implementation_)
311 errno = EFAULT;
312 return -1;
314 return this->implementation_->write (message_block,
315 bytes_to_write,
316 act,
317 priority,
318 signal_number);
321 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
323 ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block,
324 size_t bytes_to_write,
325 const void *act,
326 int priority,
327 int signal_number)
329 if (0 == this->implementation_)
331 errno = EFAULT;
332 return -1;
334 return this->implementation_->writev (message_block,
335 bytes_to_write,
336 act,
337 priority,
338 signal_number);
340 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
342 ACE_Asynch_Operation_Impl *
343 ACE_Asynch_Write_Stream::implementation (void) const
345 return this->implementation_;
348 // ************************************************************
350 size_t
351 ACE_Asynch_Write_Stream::Result::bytes_to_write (void) const
353 return this->implementation ()->bytes_to_write ();
356 ACE_Message_Block &
357 ACE_Asynch_Write_Stream::Result::message_block (void) const
359 return this->implementation ()->message_block ();
362 ACE_HANDLE
363 ACE_Asynch_Write_Stream::Result::handle (void) const
365 return this->implementation ()->handle ();
368 ACE_Asynch_Write_Stream::Result::Result (ACE_Asynch_Write_Stream_Result_Impl *implementation)
369 : ACE_Asynch_Result (implementation),
370 implementation_ (implementation)
374 ACE_Asynch_Write_Stream::Result::~Result (void)
376 // Proactor will delte the implementation when the <complete> call
377 // finishes.
380 ACE_Asynch_Write_Stream_Result_Impl *
381 ACE_Asynch_Write_Stream::Result::implementation (void) const
383 return this->implementation_;
386 // ************************************************************
388 ACE_Asynch_Read_File::ACE_Asynch_Read_File (void)
389 : implementation_ (0)
393 ACE_Asynch_Read_File::~ACE_Asynch_Read_File (void)
395 // Delete the implementation.
396 delete this->implementation_;
397 this->implementation_ = 0;
401 ACE_Asynch_Read_File::open (ACE_Handler &handler,
402 ACE_HANDLE handle,
403 const void *completion_key,
404 ACE_Proactor *proactor)
406 // Get a proactor for/from the user.
407 proactor = this->get_proactor (proactor, handler);
409 // Now let us get the implementation initialized.
410 if ((this->implementation_ = proactor->create_asynch_read_file ()) == 0)
411 return -1;
413 // Call the <open> method of the base class.
414 return ACE_Asynch_Operation::open (handler,
415 handle,
416 completion_key,
417 proactor);
421 ACE_Asynch_Read_File::read (ACE_Message_Block &message_block,
422 size_t bytes_to_read,
423 unsigned long offset,
424 unsigned long offset_high,
425 const void *act,
426 int priority,
427 int signal_number)
429 if (0 == this->implementation_)
431 errno = EFAULT;
432 return -1;
434 return this->implementation_->read (message_block,
435 bytes_to_read,
436 offset,
437 offset_high,
438 act,
439 priority,
440 signal_number);
443 #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
445 ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block,
446 size_t bytes_to_read,
447 unsigned long offset,
448 unsigned long offset_high,
449 const void *act,
450 int priority,
451 int signal_number)
453 if (0 == this->implementation_)
455 errno = EFAULT;
456 return -1;
458 return this->implementation_->readv (message_block,
459 bytes_to_read,
460 offset,
461 offset_high,
462 act,
463 priority,
464 signal_number);
466 #endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
468 ACE_Asynch_Operation_Impl *
469 ACE_Asynch_Read_File::implementation (void) const
471 return this->implementation_;
474 // ************************************************************
476 ACE_Asynch_Read_File::Result::Result (ACE_Asynch_Read_File_Result_Impl *implementation)
477 : ACE_Asynch_Read_Stream::Result (implementation),
478 implementation_ (implementation)
482 ACE_Asynch_Read_File::Result::~Result (void)
484 // Proactor will delete the implementation when <complete> call
485 // completes.
488 ACE_Asynch_Read_File_Result_Impl *
489 ACE_Asynch_Read_File::Result::implementation (void) const
491 return this->implementation_;
494 // ************************************************************
496 ACE_Asynch_Write_File::ACE_Asynch_Write_File (void)
497 : implementation_ (0)
501 ACE_Asynch_Write_File::~ACE_Asynch_Write_File (void)
503 // Delete the implementation.
504 delete this->implementation_;
505 this->implementation_ = 0;
509 ACE_Asynch_Write_File::open (ACE_Handler &handler,
510 ACE_HANDLE handle,
511 const void *completion_key,
512 ACE_Proactor *proactor)
514 // Get a proactor for/from the user.
515 proactor = this->get_proactor (proactor, handler);
517 // Now let us get the implementation initialized.
518 if ((this->implementation_ = proactor->create_asynch_write_file ()) == 0)
519 return -1;
521 // Call the <open> method of the base class.
522 return ACE_Asynch_Operation::open (handler,
523 handle,
524 completion_key,
525 proactor);
529 ACE_Asynch_Write_File::write (ACE_Message_Block &message_block,
530 size_t bytes_to_write,
531 unsigned long offset,
532 unsigned long offset_high,
533 const void *act,
534 int priority,
535 int signal_number)
537 if (0 == this->implementation_)
539 errno = EFAULT;
540 return -1;
542 return this->implementation_->write (message_block,
543 bytes_to_write,
544 offset,
545 offset_high,
546 act,
547 priority,
548 signal_number);
551 #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
553 ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block,
554 size_t bytes_to_write,
555 unsigned long offset,
556 unsigned long offset_high,
557 const void *act,
558 int priority,
559 int signal_number)
561 if (0 == this->implementation_)
563 errno = EFAULT;
564 return -1;
566 return this->implementation_->writev (message_block,
567 bytes_to_write,
568 offset,
569 offset_high,
570 act,
571 priority,
572 signal_number);
574 #endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
576 ACE_Asynch_Operation_Impl *
577 ACE_Asynch_Write_File::implementation (void) const
579 return this->implementation_;
582 // ************************************************************
584 ACE_Asynch_Write_File::Result::Result (ACE_Asynch_Write_File_Result_Impl *implementation)
585 : ACE_Asynch_Write_Stream::Result (implementation),
586 implementation_ (implementation)
590 ACE_Asynch_Write_File::Result::~Result (void)
592 // Proactor will delete the implementation when the <complete> call
593 // completes.
596 ACE_Asynch_Write_File_Result_Impl *
597 ACE_Asynch_Write_File::Result::implementation (void) const
599 return this->implementation_;
602 // *********************************************************************
604 ACE_Asynch_Accept::ACE_Asynch_Accept (void)
605 : implementation_ (0)
609 ACE_Asynch_Accept::~ACE_Asynch_Accept (void)
611 // Delete the implementation.
612 delete this->implementation_;
613 this->implementation_ = 0;
617 ACE_Asynch_Accept::open (ACE_Handler &handler,
618 ACE_HANDLE handle,
619 const void *completion_key,
620 ACE_Proactor *proactor)
622 // Get a proactor for/from the user.
623 proactor = this->get_proactor (proactor, handler);
625 // Now let us get the implementation initialized.
626 if ((this->implementation_ = proactor->create_asynch_accept ()) == 0)
627 return -1;
629 // Call the <open> method of the base class.
630 return ACE_Asynch_Operation::open (handler,
631 handle,
632 completion_key,
633 proactor);
637 ACE_Asynch_Accept::accept (ACE_Message_Block &message_block,
638 size_t bytes_to_read,
639 ACE_HANDLE accept_handle,
640 const void *act,
641 int priority,
642 int signal_number,
643 int addr_family)
645 if (0 == this->implementation_)
647 errno = EFAULT;
648 return -1;
650 return this->implementation_->accept (message_block,
651 bytes_to_read,
652 accept_handle,
653 act,
654 priority,
655 signal_number,
656 addr_family);
659 ACE_Asynch_Operation_Impl *
660 ACE_Asynch_Accept::implementation (void) const
662 return this->implementation_;
665 // ************************************************************
667 size_t
668 ACE_Asynch_Accept::Result::bytes_to_read (void) const
670 return this->implementation ()->bytes_to_read ();
673 ACE_Message_Block &
674 ACE_Asynch_Accept::Result::message_block (void) const
676 return this->implementation ()->message_block ();
679 ACE_HANDLE
680 ACE_Asynch_Accept::Result::listen_handle (void) const
682 return this->implementation ()->listen_handle ();
685 ACE_HANDLE
686 ACE_Asynch_Accept::Result::accept_handle (void) const
688 return this->implementation ()->accept_handle ();
691 ACE_Asynch_Accept::Result::Result (ACE_Asynch_Accept_Result_Impl *implementation)
692 : ACE_Asynch_Result (implementation),
693 implementation_ (implementation)
697 ACE_Asynch_Accept::Result::~Result (void)
699 // Proactor will delete the implementation when the <complete> call
700 // completes.
703 ACE_Asynch_Accept_Result_Impl *
704 ACE_Asynch_Accept::Result::implementation (void) const
706 return this->implementation_;
711 // *********************************************************************
713 ACE_Asynch_Connect::ACE_Asynch_Connect (void)
714 : implementation_ (0)
718 ACE_Asynch_Connect::~ACE_Asynch_Connect (void)
720 // Delete the implementation.
721 delete this->implementation_;
722 this->implementation_ = 0;
726 ACE_Asynch_Connect::open (ACE_Handler &handler,
727 ACE_HANDLE handle,
728 const void *completion_key,
729 ACE_Proactor *proactor)
731 // Get a proactor for/from the user.
732 proactor = this->get_proactor (proactor, handler);
734 // Now let us get the implementation initialized.
735 if ((this->implementation_ = proactor->create_asynch_connect ()) == 0)
736 return -1;
738 // Call the <open> method of the base class.
739 return ACE_Asynch_Operation::open (handler,
740 handle,
741 completion_key,
742 proactor);
746 ACE_Asynch_Connect::connect (ACE_HANDLE connect_handle,
747 const ACE_Addr & remote_sap,
748 const ACE_Addr & local_sap,
749 int reuse_addr,
750 const void *act,
751 int priority,
752 int signal_number)
754 if (0 == this->implementation_)
756 errno = EFAULT;
757 return -1;
759 return this->implementation_->connect (connect_handle,
760 remote_sap,
761 local_sap,
762 reuse_addr,
763 act,
764 priority,
765 signal_number);
768 ACE_Asynch_Operation_Impl *
769 ACE_Asynch_Connect::implementation (void) const
771 return this->implementation_;
774 // ************************************************************
776 ACE_Asynch_Connect::Result::Result (ACE_Asynch_Connect_Result_Impl *implementation)
777 : ACE_Asynch_Result (implementation),
778 implementation_ (implementation)
782 ACE_Asynch_Connect::Result::~Result (void)
784 // Proactor will delete the implementation when the <complete> call
785 // completes.
788 ACE_HANDLE
789 ACE_Asynch_Connect::Result::connect_handle (void) const
791 return this->implementation ()->connect_handle ();
795 ACE_Asynch_Connect_Result_Impl *
796 ACE_Asynch_Connect::Result::implementation (void) const
798 return this->implementation_;
801 // ************************************************************
803 ACE_Asynch_Transmit_File::ACE_Asynch_Transmit_File (void)
804 : implementation_ (0)
808 ACE_Asynch_Transmit_File::~ACE_Asynch_Transmit_File (void)
810 // Delete the implementation.
811 delete this->implementation_;
812 this->implementation_ = 0;
816 ACE_Asynch_Transmit_File::open (ACE_Handler &handler,
817 ACE_HANDLE handle,
818 const void *completion_key,
819 ACE_Proactor *proactor)
821 // Get a proactor for/from the user.
822 proactor = this->get_proactor (proactor, handler);
824 // Now let us get the implementation initialized.
825 if ((this->implementation_ = proactor->create_asynch_transmit_file ()) == 0)
826 return -1;
828 // Call the <open> method of the base class.
829 return ACE_Asynch_Operation::open (handler,
830 handle,
831 completion_key,
832 proactor);
836 ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file,
837 Header_And_Trailer *header_and_trailer,
838 size_t bytes_to_write,
839 unsigned long offset,
840 unsigned long offset_high,
841 size_t bytes_per_send,
842 unsigned long flags,
843 const void *act,
844 int priority,
845 int signal_number)
847 if (0 == this->implementation_)
849 errno = EFAULT;
850 return -1;
852 return this->implementation_->transmit_file (file,
853 header_and_trailer,
854 bytes_to_write,
855 offset,
856 offset_high,
857 bytes_per_send,
858 flags,
859 act,
860 priority,
861 signal_number);
864 ACE_Asynch_Operation_Impl *
865 ACE_Asynch_Transmit_File::implementation (void) const
867 return this->implementation_;
870 // ****************************************************************************
872 ACE_HANDLE
873 ACE_Asynch_Transmit_File::Result::socket (void) const
875 return this->implementation ()->socket ();
878 ACE_HANDLE
879 ACE_Asynch_Transmit_File::Result::file (void) const
881 return this->implementation ()->file ();
884 ACE_Asynch_Transmit_File::Header_And_Trailer *
885 ACE_Asynch_Transmit_File::Result::header_and_trailer (void) const
887 return this->implementation ()->header_and_trailer ();
890 size_t
891 ACE_Asynch_Transmit_File::Result::bytes_to_write (void) const
893 return this->implementation ()->bytes_to_write ();
896 size_t
897 ACE_Asynch_Transmit_File::Result::bytes_per_send (void) const
899 return this->implementation ()->bytes_per_send ();
902 unsigned long
903 ACE_Asynch_Transmit_File::Result::flags (void) const
905 return this->implementation ()->flags ();
908 ACE_Asynch_Transmit_File::Result::Result (ACE_Asynch_Transmit_File_Result_Impl *implementation)
909 : ACE_Asynch_Result (implementation),
910 implementation_ (implementation)
914 ACE_Asynch_Transmit_File::Result::~Result (void)
918 ACE_Asynch_Transmit_File_Result_Impl *
919 ACE_Asynch_Transmit_File::Result::implementation (void) const
921 return this->implementation_;
924 // ************************************************************
926 ACE_Asynch_Transmit_File::Header_And_Trailer::Header_And_Trailer (ACE_Message_Block *header,
927 size_t header_bytes,
928 ACE_Message_Block *trailer,
929 size_t trailer_bytes)
930 : header_ (header),
931 header_bytes_ (header_bytes),
932 trailer_ (trailer),
933 trailer_bytes_ (trailer_bytes)
937 ACE_Asynch_Transmit_File::Header_And_Trailer::~Header_And_Trailer (void)
941 void
942 ACE_Asynch_Transmit_File::Header_And_Trailer::header_and_trailer (ACE_Message_Block *header,
943 size_t header_bytes,
944 ACE_Message_Block *trailer,
945 size_t trailer_bytes)
947 this->header (header);
948 this->header_bytes (header_bytes);
949 this->trailer (trailer);
950 this->trailer_bytes (trailer_bytes);
953 ACE_Message_Block *
954 ACE_Asynch_Transmit_File::Header_And_Trailer::header (void) const
956 return this->header_;
959 void
960 ACE_Asynch_Transmit_File::Header_And_Trailer::header (ACE_Message_Block *message_block)
962 this->header_ = message_block;
965 size_t
966 ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (void) const
968 return this->header_bytes_;
971 void
972 ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (size_t bytes)
974 this->header_bytes_ = bytes;
977 ACE_Message_Block *
978 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (void) const
980 return this->trailer_;
983 void
984 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (ACE_Message_Block *message_block)
986 this->trailer_ = message_block;
989 size_t
990 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (void) const
992 return this->trailer_bytes_;
995 void
996 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (size_t bytes)
998 this->trailer_bytes_ = bytes;
1001 ACE_LPTRANSMIT_FILE_BUFFERS
1002 ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void)
1004 // If both are zero, return zero
1005 if (this->header_ == 0 && this->trailer_ == 0)
1007 return 0;
1009 else
1011 // Something is valid
1013 // If header is valid, set the fields
1014 if (this->header_ != 0)
1016 this->transmit_buffers_.Head = this->header_->rd_ptr ();
1017 #if defined (ACE_WIN64) || defined (ACE_WIN32)
1018 this->transmit_buffers_.HeadLength =
1019 ACE_Utils::truncate_cast<DWORD> (this->header_bytes_);
1020 #else
1021 this->transmit_buffers_.HeadLength = this->header_bytes_;
1022 #endif /* ACE_WIN64 || ACE_WIN32 */
1024 else
1026 this->transmit_buffers_.Head = 0;
1027 this->transmit_buffers_.HeadLength = 0;
1030 // If trailer is valid, set the fields
1031 if (this->trailer_ != 0)
1033 this->transmit_buffers_.Tail = this->trailer_->rd_ptr ();
1034 #if defined(ACE_WIN64) || defined (ACE_WIN32)
1035 this->transmit_buffers_.TailLength =
1036 ACE_Utils::truncate_cast<DWORD> (this->trailer_bytes_);
1037 #else
1038 this->transmit_buffers_.TailLength = this->trailer_bytes_;
1039 #endif /* ACE_WIN64 || ACE_WIN32 */
1041 else
1043 this->transmit_buffers_.Tail = 0;
1044 this->transmit_buffers_.TailLength = 0;
1047 // Return the transmit buffers
1048 return &this->transmit_buffers_;
1052 // *********************************************************************
1054 ACE_Handler::ACE_Handler (void)
1055 : proactor_ (0), handle_ (ACE_INVALID_HANDLE)
1057 ACE_Handler::Proxy *p;
1058 ACE_NEW (p, ACE_Handler::Proxy (this));
1059 this->proxy_.reset (p);
1062 ACE_Handler::ACE_Handler (ACE_Proactor *d)
1063 : proactor_ (d), handle_ (ACE_INVALID_HANDLE)
1065 ACE_Handler::Proxy *p;
1066 ACE_NEW (p, ACE_Handler::Proxy (this));
1067 this->proxy_.reset (p);
1070 ACE_Handler::~ACE_Handler (void)
1072 ACE_Handler::Proxy *p = this->proxy_.get ();
1073 if (p)
1074 p->reset ();
1077 void
1078 ACE_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result & /* result */)
1082 void
1083 ACE_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result & /* result */)
1087 void
1088 ACE_Handler::handle_write_dgram (const ACE_Asynch_Write_Dgram::Result & /* result */)
1092 void
1093 ACE_Handler::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result & /* result */)
1097 void
1098 ACE_Handler::handle_accept (const ACE_Asynch_Accept::Result & /* result */)
1102 void
1103 ACE_Handler::handle_connect (const ACE_Asynch_Connect::Result & /* result */)
1107 void
1108 ACE_Handler::handle_transmit_file (const ACE_Asynch_Transmit_File::Result & /* result */)
1112 void
1113 ACE_Handler::handle_read_file (const ACE_Asynch_Read_File::Result & /* result */)
1117 void
1118 ACE_Handler::handle_write_file (const ACE_Asynch_Write_File::Result & /* result */)
1122 void
1123 ACE_Handler::handle_time_out (const ACE_Time_Value & /* tv */,
1124 const void * /* act */)
1128 void
1129 ACE_Handler::handle_wakeup (void)
1133 ACE_Proactor *
1134 ACE_Handler::proactor (void)
1136 return this->proactor_;
1139 void
1140 ACE_Handler::proactor (ACE_Proactor *p)
1142 this->proactor_ = p;
1145 ACE_HANDLE
1146 ACE_Handler::handle (void) const
1148 return this->handle_;
1151 void
1152 ACE_Handler::handle (ACE_HANDLE h)
1154 this->handle_ = h;
1157 ACE_Refcounted_Auto_Ptr<ACE_Handler::Proxy, ACE_SYNCH_MUTEX> &
1158 ACE_Handler::proxy (void)
1160 return this->proxy_;
1163 // ************************************************************
1165 ACE_Service_Handler::ACE_Service_Handler (void)
1169 ACE_Service_Handler::~ACE_Service_Handler (void)
1173 void
1174 ACE_Service_Handler::addresses (const ACE_INET_Addr & /* remote_address */,
1175 const ACE_INET_Addr & /* local_address */ )
1179 void
1180 ACE_Service_Handler::act (const void *)
1184 void
1185 ACE_Service_Handler::open (ACE_HANDLE,
1186 ACE_Message_Block &)
1191 // ************************************************************
1193 ACE_Asynch_Read_Dgram::ACE_Asynch_Read_Dgram (void)
1194 : implementation_ (0)
1198 ACE_Asynch_Read_Dgram::~ACE_Asynch_Read_Dgram (void)
1200 // Delete the implementation.
1201 delete this->implementation_;
1202 this->implementation_ = 0;
1206 ACE_Asynch_Read_Dgram::open (ACE_Handler &handler,
1207 ACE_HANDLE handle,
1208 const void *completion_key,
1209 ACE_Proactor *proactor)
1211 // Get a proactor for/from the user.
1212 proactor = this->get_proactor (proactor, handler);
1214 // Now let us get the implementation initialized.
1215 if ((this->implementation_ = proactor->create_asynch_read_dgram ()) == 0)
1216 return -1;
1218 // Call the <open> method of the base class.
1219 return ACE_Asynch_Operation::open (handler,
1220 handle,
1221 completion_key,
1222 proactor);
1225 ssize_t
1226 ACE_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block,
1227 size_t &number_of_bytes_recvd,
1228 int flags,
1229 int protocol_family,
1230 const void *act,
1231 int priority,
1232 int signal_number)
1234 if (0 == this->implementation_)
1236 errno = EFAULT;
1237 return -1;
1239 return this->implementation_->recv (message_block,
1240 number_of_bytes_recvd,
1241 flags,
1242 protocol_family,
1243 act,
1244 priority,
1245 signal_number);
1248 ACE_Asynch_Operation_Impl *
1249 ACE_Asynch_Read_Dgram::implementation (void) const
1251 return this->implementation_;
1254 // ************************************************************
1257 ACE_Asynch_Read_Dgram::Result::remote_address (ACE_Addr& addr) const
1259 return this->implementation ()->remote_address (addr);
1262 ACE_Message_Block*
1263 ACE_Asynch_Read_Dgram::Result::message_block (void) const
1265 return this->implementation ()->message_block ();
1269 ACE_Asynch_Read_Dgram::Result::flags (void) const
1271 return this->implementation ()->flags ();
1274 size_t
1275 ACE_Asynch_Read_Dgram::Result::bytes_to_read (void) const
1277 return this->implementation ()->bytes_to_read ();
1280 ACE_HANDLE
1281 ACE_Asynch_Read_Dgram::Result::handle (void) const
1283 return this->implementation ()->handle();
1286 ACE_Asynch_Read_Dgram::Result::Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation)
1287 : ACE_Asynch_Result (implementation),
1288 implementation_ (implementation)
1292 ACE_Asynch_Read_Dgram::Result::~Result (void)
1296 ACE_Asynch_Read_Dgram_Result_Impl *
1297 ACE_Asynch_Read_Dgram::Result::implementation (void) const
1299 return this->implementation_;
1302 // ************************************************************
1305 ACE_Asynch_Write_Dgram::ACE_Asynch_Write_Dgram (void)
1306 : implementation_ (0)
1310 ACE_Asynch_Write_Dgram::~ACE_Asynch_Write_Dgram (void)
1312 // Delete the implementation.
1313 delete this->implementation_;
1314 this->implementation_ = 0;
1318 ACE_Asynch_Write_Dgram::open (ACE_Handler &handler,
1319 ACE_HANDLE handle,
1320 const void *completion_key,
1321 ACE_Proactor *proactor)
1323 // Get a proactor for/from the user.
1324 proactor = this->get_proactor (proactor, handler);
1326 // Now let us get the implementation initialized.
1327 if ((this->implementation_ = proactor->create_asynch_write_dgram ()) == 0)
1328 return -1;
1330 // Call the <open> method of the base class.
1331 return ACE_Asynch_Operation::open (handler,
1332 handle,
1333 completion_key,
1334 proactor);
1337 ssize_t
1338 ACE_Asynch_Write_Dgram::send (ACE_Message_Block *message_block,
1339 size_t &number_of_bytes_sent,
1340 int flags,
1341 const ACE_Addr& remote_addr,
1342 const void *act,
1343 int priority,
1344 int signal_number)
1346 if (0 == this->implementation_)
1348 errno = EFAULT;
1349 return -1;
1351 return this->implementation_->send (message_block,
1352 number_of_bytes_sent,
1353 flags,
1354 remote_addr,
1355 act,
1356 priority,
1357 signal_number);
1360 ACE_Asynch_Operation_Impl *
1361 ACE_Asynch_Write_Dgram::implementation (void) const
1363 return this->implementation_;
1366 // ************************************************************
1368 size_t
1369 ACE_Asynch_Write_Dgram::Result::bytes_to_write (void) const
1371 return this->implementation ()->bytes_to_write ();
1374 ACE_Message_Block*
1375 ACE_Asynch_Write_Dgram::Result::message_block () const
1377 return this->implementation ()->message_block ();
1381 ACE_Asynch_Write_Dgram::Result::flags (void) const
1383 return this->implementation ()->flags ();
1386 ACE_HANDLE
1387 ACE_Asynch_Write_Dgram::Result::handle (void) const
1389 return this->implementation ()->handle ();
1392 ACE_Asynch_Write_Dgram_Result_Impl *
1393 ACE_Asynch_Write_Dgram::Result::implementation (void) const
1395 return this->implementation_;
1398 ACE_Asynch_Write_Dgram::Result::Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation)
1399 : ACE_Asynch_Result (implementation),
1400 implementation_ (implementation)
1404 ACE_Asynch_Write_Dgram::Result::~Result (void)
1408 ACE_END_VERSIONED_NAMESPACE_DECL
1410 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */