ACE_WIN32_Asynch_Transmit_File Class Reference

This class is a factory for starting off asynchronous transmit files on a stream. More...

#include <WIN32_Asynch_IO.h>

Inheritance diagram for ACE_WIN32_Asynch_Transmit_File:

Inheritance graph
[legend]
Collaboration diagram for ACE_WIN32_Asynch_Transmit_File:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_WIN32_Asynch_Transmit_File (ACE_WIN32_Proactor *win32_proactor)
 Constructor.

int transmit_file (ACE_HANDLE file, ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, size_t bytes_to_write, u_long offset, u_long offset_high, size_t bytes_per_send, u_long flags, const void *act, int priority, int signal_number=0)
 ~ACE_WIN32_Asynch_Transmit_File (void)
 Destructor.

int open (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, const void *completion_key, ACE_Proactor *proactor)
int cancel (void)
ACE_Proactorproactor (void) const
 Return the underlying proactor.


Detailed Description

This class is a factory for starting off asynchronous transmit files on a stream.

Once is called, multiple asynchronous s can started using this class. A ACE_Asynch_Transmit_File::Result will be passed back to the when the asynchronous transmit file completes through the <ACE_Handler::handle_transmit_file> callback.

The transmit_file function transmits file data over a connected network connection. The function uses the operating system's cache manager to retrieve the file data. This function provides high-performance file data transfer over network connections. This function would be of great use in a Web Server, Image Server, etc.

Definition at line 1495 of file WIN32_Asynch_IO.h.


Constructor & Destructor Documentation

ACE_WIN32_Asynch_Transmit_File::ACE_WIN32_Asynch_Transmit_File ACE_WIN32_Proactor win32_proactor  ) 
 

Constructor.

Definition at line 2935 of file WIN32_Asynch_IO.cpp.

02936   : ACE_Asynch_Operation_Impl (),
02937     ACE_Asynch_Transmit_File_Impl (),
02938     ACE_WIN32_Asynch_Operation (win32_proactor)
02939 {
02940 }

ACE_WIN32_Asynch_Transmit_File::~ACE_WIN32_Asynch_Transmit_File void   ) 
 

Destructor.

Definition at line 3037 of file WIN32_Asynch_IO.cpp.

03038 {
03039 }


Member Function Documentation

int ACE_WIN32_Asynch_Transmit_File::cancel void   )  [virtual]
 

This cancels all pending accepts operations that were issued by the calling thread. The function does not cancel asynchronous operations issued by other threads.

Reimplemented from ACE_WIN32_Asynch_Operation.

Definition at line 3058 of file WIN32_Asynch_IO.cpp.

References ACE_WIN32_Asynch_Operation::cancel().

03059 {
03060   return ACE_WIN32_Asynch_Operation::cancel ();
03061 }

int ACE_WIN32_Asynch_Transmit_File::open const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  handle,
const void *  completion_key,
ACE_Proactor proactor
[virtual]
 

Initializes the factory with information which will be used with each asynchronous call. If ( == ACE_INVALID_HANDLE), <ACE_Handler::handle> will be called on the to get the correct handle.

Reimplemented from ACE_WIN32_Asynch_Operation.

Definition at line 3046 of file WIN32_Asynch_IO.cpp.

References ACE_WIN32_Asynch_Operation::open(), and ACE_Handler::Proxy_Ptr.

03050 {
03051   return ACE_WIN32_Asynch_Operation::open (handler_proxy,
03052                                            handle,
03053                                            completion_key,
03054                                            proactor);
03055 }

ACE_Proactor * ACE_WIN32_Asynch_Transmit_File::proactor void   )  const [virtual]
 

Return the underlying proactor.

Reimplemented from ACE_WIN32_Asynch_Operation.

Definition at line 3064 of file WIN32_Asynch_IO.cpp.

References ACE_WIN32_Asynch_Operation::proactor().

03065 {
03066   return ACE_WIN32_Asynch_Operation::proactor ();
03067 }

int ACE_WIN32_Asynch_Transmit_File::transmit_file ACE_HANDLE  file,
ACE_Asynch_Transmit_File::Header_And_Trailer header_and_trailer,
size_t  bytes_to_write,
u_long  offset,
u_long  offset_high,
size_t  bytes_per_send,
u_long  flags,
const void *  act,
int  priority,
int  signal_number = 0
[virtual]
 

This starts off an asynchronous transmit file. The is a handle to an open file. is a pointer to a data structure that contains pointers to data to send before and after the file data is sent. Set this parameter to 0 if you only want to transmit the file data. Upto will be written to the . If you want to send the entire file, let = 0. is the size of each block of data sent per send operation. Please read the Win32 documentation on what the flags should be.

Implements ACE_Asynch_Transmit_File_Impl.

Definition at line 2943 of file WIN32_Asynch_IO.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_LPTRANSMIT_FILE_BUFFERS, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE::debug(), ACE_WIN32_Asynch_Transmit_File_Result::file(), ACE_WIN32_Asynch_Transmit_File_Result::flags(), ACE_WIN32_Asynch_Transmit_File_Result::header_and_trailer(), LM_ERROR, ACE_OS::set_errno_to_last_error(), ACE_WIN32_Asynch_Transmit_File_Result::socket(), and ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers().

02953 {
02954 #if (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
02955 
02956   // TransmitFile API limits us to DWORD range.
02957   if (bytes_to_write > MAXDWORD || bytes_per_send > MAXDWORD)
02958     {
02959       errno = ERANGE;
02960       return -1;
02961     }
02962   DWORD dword_bytes_to_write = static_cast<DWORD> (bytes_to_write);
02963   DWORD dword_bytes_per_send = static_cast<DWORD> (bytes_per_send);
02964 
02965   ACE_WIN32_Asynch_Transmit_File_Result *result = 0;
02966   ACE_NEW_RETURN (result,
02967                   ACE_WIN32_Asynch_Transmit_File_Result (this->handler_proxy_,
02968                                                          this->handle_,
02969                                                          file,
02970                                                          header_and_trailer,
02971                                                          bytes_to_write,
02972                                                          offset,
02973                                                          offset_high,
02974                                                          bytes_per_send,
02975                                                          flags,
02976                                                          act,
02977                                                          this->win32_proactor_->get_handle (),
02978                                                          priority,
02979                                                          signal_number),
02980                   -1);
02981 
02982   ACE_LPTRANSMIT_FILE_BUFFERS transmit_buffers = 0;
02983   if (result->header_and_trailer () != 0)
02984     transmit_buffers = result->header_and_trailer ()->transmit_buffers ();
02985 
02986   // Initiate the transmit file
02987   int initiate_result = ::TransmitFile ((SOCKET) result->socket (),
02988                                         result->file (),
02989                                         dword_bytes_to_write,
02990                                         dword_bytes_per_send,
02991                                         result,
02992                                         transmit_buffers,
02993                                         result->flags ());
02994   if (initiate_result == 1)
02995     // Immediate success: the OVERLAPPED will still get queued.
02996     return 1;
02997 
02998   // If initiate failed, check for a bad error.
02999   ACE_OS::set_errno_to_last_error ();
03000   switch (errno)
03001     {
03002     case ERROR_IO_PENDING:
03003       // The IO will complete proactively: the OVERLAPPED will still
03004       // get queued.
03005       return 0;
03006 
03007     default:
03008       // Something else went wrong: the OVERLAPPED will not get
03009       // queued.
03010 
03011       // Cleanup dynamically allocated Asynch_Result
03012       delete result;
03013 
03014       if (ACE::debug ())
03015         {
03016           ACE_DEBUG ((LM_ERROR,
03017                       ACE_LIB_TEXT ("%p\n"),
03018                       ACE_LIB_TEXT ("TransmitFile")));
03019         }
03020       return -1;
03021     }
03022 #else /* (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)) */
03023   ACE_UNUSED_ARG (file);
03024   ACE_UNUSED_ARG (header_and_trailer);
03025   ACE_UNUSED_ARG (bytes_to_write);
03026   ACE_UNUSED_ARG (offset);
03027   ACE_UNUSED_ARG (offset_high);
03028   ACE_UNUSED_ARG (bytes_per_send);
03029   ACE_UNUSED_ARG (flags);
03030   ACE_UNUSED_ARG (act);
03031   ACE_UNUSED_ARG (priority);
03032   ACE_UNUSED_ARG (signal_number);
03033   ACE_NOTSUP_RETURN (-1);
03034 #endif /* ACE_HAS_AIO_CALLS */
03035 }


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:33:08 2006 for ACE by doxygen 1.3.6