Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 Methods

 ACE_WIN32_Asynch_Transmit_File (ACE_WIN32_Proactor *win32_proactor)
 Constructor. More...

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. More...

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


Detailed Description

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

Once <open> is called, multiple asynchronous <transmit_file>s can started using this class. A ACE_Asynch_Transmit_File::Result will be passed back to the <handler> 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 1505 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 2942 of file WIN32_Asynch_IO.cpp.

02943   : ACE_Asynch_Operation_Impl (),
02944     ACE_Asynch_Transmit_File_Impl (),
02945     ACE_WIN32_Asynch_Operation (win32_proactor)
02946 {
02947 }

ACE_WIN32_Asynch_Transmit_File::~ACE_WIN32_Asynch_Transmit_File void   
 

Destructor.

Definition at line 3044 of file WIN32_Asynch_IO.cpp.

03045 {
03046 }


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 3065 of file WIN32_Asynch_IO.cpp.

References ACE_WIN32_Asynch_Operation::cancel.

03066 {
03067   return ACE_WIN32_Asynch_Operation::cancel ();
03068 }

int ACE_WIN32_Asynch_Transmit_File::open ACE_Handler   handler,
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 (<handle> == ACE_INVALID_HANDLE), <ACE_Handler::handle> will be called on the <handler> to get the correct handle.

Reimplemented from ACE_WIN32_Asynch_Operation.

Definition at line 3053 of file WIN32_Asynch_IO.cpp.

References ACE_WIN32_Asynch_Operation::open.

03057 {
03058   return ACE_WIN32_Asynch_Operation::open (handler,
03059                                            handle,
03060                                            completion_key,
03061                                            proactor);
03062 }

ACE_Proactor * ACE_WIN32_Asynch_Transmit_File::proactor void    const [virtual]
 

Return the underlying proactor.

Reimplemented from ACE_WIN32_Asynch_Operation.

Definition at line 3071 of file WIN32_Asynch_IO.cpp.

References ACE_WIN32_Asynch_Operation::proactor.

03072 {
03073   return ACE_WIN32_Asynch_Operation::proactor ();
03074 }

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 <file> is a handle to an open file. <header_and_trailer> 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 <bytes_to_write> will be written to the <socket>. If you want to send the entire file, let <bytes_to_write> = 0. <bytes_per_send> 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 2950 of file WIN32_Asynch_IO.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_LPTRANSMIT_FILE_BUFFERS, ACE_NEW_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.

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


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 13:00:27 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002