3 ** Example program from The ACE Programmer's Guide, Chapter 8.
4 ** Copyright 2003 Addison-Wesley. All Rights Reserved.
7 #ifndef __HA_PROACTIVE_STATUS_H
8 #define __HA_PROACTIVE_STATUS_H
10 #include "ace/OS_NS_sys_socket.h"
11 #include "ace/Asynch_IO.h"
12 #include "ace/Service_Object.h"
13 // Listing 1 code/ch08
14 #include "ace/Asynch_IO.h"
16 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
18 class HA_Proactive_Service
: public ACE_Service_Handler
21 ~HA_Proactive_Service ()
23 if (this->handle () != ACE_INVALID_HANDLE
)
24 ACE_OS::closesocket (this->handle ());
27 virtual void open (ACE_HANDLE h
, ACE_Message_Block
&);
29 // This method will be called when an asynchronous read
30 // completes on a stream.
31 virtual void handle_read_stream
32 (const ACE_Asynch_Read_Stream::Result
&result
);
34 // This method will be called when an asynchronous write
35 // completes on a stream.
36 virtual void handle_write_stream
37 (const ACE_Asynch_Write_Stream::Result
&result
);
40 ACE_Asynch_Read_Stream reader_
;
41 ACE_Asynch_Write_Stream writer_
;
45 // Listing 2 code/ch08
46 #include "ace/Asynch_Acceptor.h"
47 #include "ace/INET_Addr.h"
49 class HA_Proactive_Acceptor
:
50 public ACE_Asynch_Acceptor
<HA_Proactive_Service
>
53 virtual int validate_connection
54 (const ACE_Asynch_Accept::Result
& result
,
55 const ACE_INET_Addr
&remote
,
56 const ACE_INET_Addr
&local
);
60 #endif /* ACE_WIN32 || ACE_HAS_AIO_CALLS */
63 // Listing 3 code/ch08
64 template <class HANDLER
>
65 class ACE_Asynch_Acceptor
: public ACE_Handler
68 virtual HANDLER
*make_handler ()
75 class HA_Proactive_Status
: public ACE_Service_Object
78 // Initializes object when dynamic linking occurs.
79 virtual int init (int argc
, ACE_TCHAR
*argv
[]);
81 // Terminates object when dynamic unlinking occurs.
85 #endif /* __HA_PROACTIVE_STATUS_H */