---
name: "ACE_Asynch_Transmit_File"
section: "3"
platform: "linux"
package: "libace-doc"
version: "5.0.7-4"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/ACE_Asynch_Transmit_File"
---

# ACE\_Asynch\_Transmit\_File(3)

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

## NAME

ACE\_Asynch\_Transmit\_File -

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

## SYNOPSIS

```
class ACE_Asynch_Transmit_File : public ACE_Asynch_Operation
{
  public:
    ACE_Asynch_Transmit_File (void);
    virtual ~ACE_Asynch_Transmit_File (void);
    int open (
        ACE_Handler &handler,
        ACE_HANDLE handle = ACE_INVALID_HANDLE,
        const void *completion_key = 0,
        ACE_Proactor *proactor = 0
        );
    int transmit_file (
        ACE_HANDLE file,
        Header_And_Trailer *header_and_trailer = 0,
        u_long bytes_to_write = 0,
        u_long offset = 0,
        u_long offset_high = 0,
        u_long bytes_per_send = 0,
        u_long flags = 0,
        const void *act = 0,
        int priority = 0,
        int signal_number = ACE_SIGRTMIN
        );
    ACE_Asynch_Transmit_File_Impl *implementation (void) const;
    class Result : public ACE_Asynch_Result
    {
      public:
        friend class ACE_POSIX_Asynch_Read_Stream_Result;
        friend class ACE_WIN32_Asynch_Read_Stream_Result;
        u_long bytes_to_read (void) const;
        ACE_Message_Block &message_block (void) const;
        ACE_HANDLE handle (void) const;
        ACE_Asynch_Read_Stream_Result_Impl *implementation (
            void
            ) const;
        friend class ACE_POSIX_Asynch_Write_Stream_Result;
        friend class ACE_WIN32_Asynch_Write_Stream_Result;
        u_long bytes_to_write (void) const;
        ACE_Message_Block &message_block (void) const;
        ACE_HANDLE handle (void) const;
        ACE_Asynch_Write_Stream_Result_Impl *implementation (
            void
            ) const;
        friend class ACE_POSIX_Asynch_Read_File_Result;
        friend class ACE_WIN32_Asynch_Read_File_Result;
        ACE_Asynch_Read_File_Result_Impl *implementation (void) const;
        friend class ACE_POSIX_Asynch_Write_File_Result;
        friend class ACE_WIN32_Asynch_Write_File_Result;
        ACE_Asynch_Write_File_Result_Impl *implementation (
            void
            ) const;
        friend class ACE_POSIX_Asynch_Accept_Result;
        friend class ACE_WIN32_Asynch_Accept_Result;
        u_long bytes_to_read (void) const;
        ACE_Message_Block &message_block (void) const;
        ACE_HANDLE listen_handle (void) const;
        ACE_HANDLE accept_handle (void) const;
        ACE_Asynch_Accept_Result_Impl *implementation (void) const;
        friend class ACE_POSIX_Asynch_Transmit_File_Result;
        friend class ACE_WIN32_Asynch_Transmit_File_Result;
        ACE_HANDLE socket (void) const;
        ACE_HANDLE file (void) const;
        Header_And_Trailer *header_and_trailer (void) const;
        u_long bytes_to_write (void) const;
        u_long bytes_per_send (void) const;
        u_long flags (void) const;
        ACE_Asynch_Transmit_File_Result_Impl *implementation (
            void
            ) const;
      protected:
        Result (ACE_Asynch_Read_Stream_Result_Impl *implementation);
        virtual ~Result (void);
        ACE_Asynch_Read_Stream_Result_Impl *implementation_;
        Result (ACE_Asynch_Write_Stream_Result_Impl *implementation);
        virtual ~Result (void);
        ACE_Asynch_Write_Stream_Result_Impl *implementation_;
        Result (ACE_Asynch_Read_File_Result_Impl *implementation);
        virtual ~Result (void);
        ACE_Asynch_Read_File_Result_Impl *implementation_;
        Result (ACE_Asynch_Write_File_Result_Impl *implementation);
        virtual ~Result (void);
        ACE_Asynch_Write_File_Result_Impl *implementation_;
        Result (ACE_Asynch_Accept_Result_Impl *implementation);
        virtual ~Result (void);
        ACE_Asynch_Accept_Result_Impl *implementation_;
        Result (ACE_Asynch_Transmit_File_Result_Impl *implementation);
        virtual ~Result (void);
        ACE_Asynch_Transmit_File_Result_Impl *implementation_;
    };
```

  protected:     void implementation (ACE\_Asynch\_Transmit\_File\_Impl \*);     ACE\_Asynch\_Transmit\_File\_Impl \*implementation\_;

    class Header\_And\_Trailer\
     {\
       public:         Header\_And\_Trailer (\
             ACE\_Message\_Block \*header = 0,\
             u\_long header\_bytes = 0,\
             ACE\_Message\_Block \*trailer = 0,\
             u\_long trailer\_bytes = 0\
             );         virtual ~Header\_And\_Trailer (void);         void header\_and\_trailer (\
             ACE\_Message\_Block \*header = 0,\
             u\_long header\_bytes = 0,\
             ACE\_Message\_Block \*trailer = 0,\
             u\_long trailer\_bytes = 0\
             );         ACE\_Message\_Block \*header (void) const;         void header (ACE\_Message\_Block \*message\_block);         u\_long header\_bytes (void) const;         void header\_bytes (u\_long bytes);         ACE\_Message\_Block \*trailer (void) const;         void trailer (ACE\_Message\_Block \*message\_block);         u\_long trailer\_bytes (void) const;         void trailer\_bytes (u\_long bytes);         ACE\_LPTRANSMIT\_FILE\_BUFFERS transmit\_buffers (void);\
       protected:         ACE\_Message\_Block \*header\_;         u\_long header\_bytes\_;         ACE\_Message\_Block \*trailer\_;         u\_long trailer\_bytes\_;         ACE\_TRANSMIT\_FILE\_BUFFERS transmit\_buffers\_;\
     }; };

## DESCRIPTION

This works on Win32 (#if defined (ACE\_WIN32) && !defined (ACE\_HAS\_WINCE)) platforms and on POSIX4 platforms with aio\_\* routines (#if defined (ACE\_HAS\_AIO\_CALLS))

On Win32 platforms, the implementation of ACE\_Asynch\_Transmit\_File and ACE\_Asynch\_Accept are only supported if ACE\_HAS\_WINSOCK2 is defined or you are on WinNT 4.0 or higher.

## PUBLIC MEMBERS

```
ACE_Asynch_Transmit_File (void);
```

A do nothing constructor.

```
virtual ~ACE_Asynch_Transmit_File (void);
```

Destructor.

```
int open (
    ACE_Handler &handler,
    ACE_HANDLE handle = ACE_INVALID_HANDLE,
    const void *completion_key = 0,
    ACE_Proactor *proactor = 0
    );
```

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.

```
int transmit_file (
    ACE_HANDLE file,
    Header_And_Trailer *header_and_trailer = 0,
    u_long bytes_to_write = 0,
    u_long offset = 0,
    u_long offset_high = 0,
    u_long bytes_per_send = 0,
    u_long flags = 0,
    const void *act = 0,
    int priority = 0,
    int signal_number = ACE_SIGRTMIN
    );
```

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. Priority of the operation is specified by priority. On POSIX4-Unix, this is supported. Works like nice in Unix. Negative values are not allowed. 0 means priority of the operation same as the process priority. 1 means priority of the operation is one less than process. And so forth. On Win32, this is a no-op. signal\_number is the POSIX4 real-time signal number to be used  for the operation. signal\_number ranges from ACE\_SIGRTMIN to ACE\_SIGRTMAX. This argument is a no-op on non-POSIX4 systems.

```
ACE_Asynch_Transmit_File_Impl *implementation (void) const;
```

Return the underlying implementation class.

## PROTECTED MEMBERS

```
void implementation (ACE_Asynch_Transmit_File_Impl *);
```

Set the implementation.

```
ACE_Asynch_Transmit_File_Impl *implementation_;
```

The implementation class.

## AUTHOR

Irfan Pyarali irfan@cs.wustl.edu, Tim Harrison harrison@cs.wustl.edu and Alexander Babu Arulanthu alex@cs.wustl.edu

## LIBRARY

ace
