#include <POSIX_Asynch_IO.h>
Inheritance diagram for ACE_POSIX_Asynch_Transmit_File:


Public Methods | |
| ACE_POSIX_Asynch_Transmit_File (ACE_POSIX_Proactor *posix_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) |
| virtual | ~ACE_POSIX_Asynch_Transmit_File (void) |
| Destructor. More... | |
Definition at line 1018 of file POSIX_Asynch_IO.h.
|
|
Constructor.
Definition at line 2226 of file POSIX_Asynch_IO.cpp.
02227 : ACE_Asynch_Operation_Impl (), 02228 ACE_Asynch_Transmit_File_Impl (), 02229 ACE_POSIX_Asynch_Operation (posix_proactor) 02230 { 02231 } |
|
|
Destructor.
Definition at line 2305 of file POSIX_Asynch_IO.cpp.
02306 {
02307 }
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
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 POSIX documentation on what the flags should be. Implements ACE_Asynch_Transmit_File_Impl. Definition at line 2234 of file POSIX_Asynch_IO.cpp. References ACE_ERROR_RETURN, ACE_NEW_RETURN, ACE_OS::filesize, LM_ERROR, ssize_t, and ACE_POSIX_Asynch_Transmit_Handler::transmit.
02244 {
02245 // Adjust these parameters if there are default values specified.
02246 ssize_t file_size = ACE_OS::filesize (file);
02247
02248 if (file_size == -1)
02249 ACE_ERROR_RETURN ((LM_ERROR,
02250 "Error:%N:%l:%p\n",
02251 "POSIX_Asynch_Transmit_File:filesize failed"),
02252 -1);
02253
02254 if (bytes_to_write == 0)
02255 bytes_to_write = file_size;
02256
02257 if (offset > (size_t) file_size)
02258 ACE_ERROR_RETURN ((LM_ERROR,
02259 "Error:%p\n",
02260 "Asynch_Transmit_File:File size is less than offset"),
02261 -1);
02262
02263 if (offset != 0)
02264 bytes_to_write = file_size - offset + 1;
02265
02266 if (bytes_per_send == 0)
02267 bytes_per_send = bytes_to_write;
02268
02269 // Configure the result parameter.
02270 ACE_POSIX_Asynch_Transmit_File_Result *result = 0;
02271
02272 ACE_NEW_RETURN (result,
02273 ACE_POSIX_Asynch_Transmit_File_Result (*this->handler_,
02274 this->handle_,
02275 file,
02276 header_and_trailer,
02277 bytes_to_write,
02278 offset,
02279 offset_high,
02280 bytes_per_send,
02281 flags,
02282 act,
02283 this->posix_proactor ()->get_handle (),
02284 priority,
02285 signal_number),
02286 -1);
02287
02288 // Make the auxillary handler and initiate transmit.
02289 ACE_POSIX_Asynch_Transmit_Handler *transmit_handler = 0;
02290
02291 ACE_NEW_RETURN (transmit_handler,
02292 ::ACE_POSIX_Asynch_Transmit_Handler (this->posix_proactor (),
02293 result),
02294 -1);
02295
02296 ssize_t return_val = transmit_handler->transmit ();
02297
02298 if (return_val == -1)
02299 // This deletes the <result> in it too.
02300 delete transmit_handler;
02301
02302 return 0;
02303 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002