3 //=============================================================================
9 //=============================================================================
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Asynch_IO.h"
22 #include "ace/SOCK_Stream.h"
23 #include "ace/Singleton.h"
24 #include "ace/Synch_Traits.h"
26 #include "JAWS/Export.h"
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 class ACE_Message_Block
;
30 ACE_END_VERSIONED_NAMESPACE_DECL
32 class JAWS_IO_Handler
;
33 class JAWS_IO_Acceptor
;
38 * @brief This class defines the abstract interface for an I/O class in
39 * the context of Web-likes servers
41 * An I/O class should have the following interface. Derived
42 * classes will define the exactly how the I/O will take place
43 * (Asynchronous, Synchronous, Reactive)
45 class JAWS_Export JAWS_IO
49 virtual ~JAWS_IO (void);
51 // void acceptor (JAWS_IO_Acceptor *acceptor);
52 // void handler (JAWS_IO_Handler *handler);
53 // void handle (ACE_HANDLE h);
54 // ACE_HANDLE handle (void);
56 // James, please add documentation here.
58 /// accept a passive connection
59 virtual void accept (JAWS_IO_Handler
*ioh
,
60 ACE_Message_Block
*mb
= 0,
61 unsigned int size
= 0) = 0;
63 /// read from the handle size bytes into the message block.
64 virtual void read (JAWS_IO_Handler
*ioh
,
65 ACE_Message_Block
*mb
,
66 unsigned int size
) = 0;
68 /// send header, filename, trailer to the handle.
69 virtual void transmit_file (JAWS_IO_Handler
*ioh
,
72 unsigned int header_size
,
74 unsigned int trailer_size
) = 0;
76 /// send header, filename, trailer to the handle.
77 virtual void transmit_file (JAWS_IO_Handler
*ioh
,
80 unsigned int header_size
,
82 unsigned int trailer_size
) = 0;
84 /// read data from the handle and store in filename.
85 virtual void receive_file (JAWS_IO_Handler
*ioh
,
88 unsigned int initial_data_length
,
89 unsigned int entire_length
) = 0;
91 /// send a confirmation message to the handle.
92 virtual void send_confirmation_message (JAWS_IO_Handler
*ioh
,
94 unsigned int length
) = 0;
96 /// send an error message to the handle.
97 virtual void send_error_message (JAWS_IO_Handler
*ioh
,
99 unsigned int length
) = 0;
103 JAWS_IO_Handler
*handler_
;
104 ACE_INET_Addr
*inet_addr_
;
105 JAWS_IO_Acceptor
*acceptor_
;
109 * @class JAWS_Synch_IO
111 * @brief This class defines the interface for a Synchronous I/O class.
113 class JAWS_Export JAWS_Synch_IO
: public JAWS_IO
116 JAWS_Synch_IO (void);
118 virtual ~JAWS_Synch_IO (void);
120 virtual void accept (JAWS_IO_Handler
*ioh
,
121 ACE_Message_Block
*mb
= 0,
122 unsigned int size
= 0);
124 virtual void read (JAWS_IO_Handler
*ioh
,
125 ACE_Message_Block
*mb
,
128 virtual void transmit_file (JAWS_IO_Handler
*ioh
,
131 unsigned int header_size
,
133 unsigned int trailer_size
);
135 virtual void transmit_file (JAWS_IO_Handler
*ioh
,
136 const char *filename
,
138 unsigned int header_size
,
140 unsigned int trailer_size
);
142 virtual void receive_file (JAWS_IO_Handler
*ioh
,
143 const char *filename
,
145 unsigned int initial_data_length
,
146 unsigned int entire_length
);
148 virtual void send_confirmation_message (JAWS_IO_Handler
*ioh
,
150 unsigned int length
);
152 virtual void send_error_message (JAWS_IO_Handler
*ioh
,
154 unsigned int length
);
157 virtual void send_message (JAWS_IO_Handler
*ioh
,
159 unsigned int length
);
162 typedef ACE_Singleton
<JAWS_Synch_IO
, ACE_SYNCH_MUTEX
>
163 JAWS_Synch_IO_Singleton
;
165 // This only works on asynch I/O-capable systems.
166 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
169 * @class JAWS_Asynch_IO
171 * @brief This class defines the interface for a Asynchronous I/O class.
173 class JAWS_Export JAWS_Asynch_IO
: public JAWS_IO
176 JAWS_Asynch_IO (void);
178 virtual ~JAWS_Asynch_IO (void);
180 virtual void accept (JAWS_IO_Handler
*ioh
,
181 ACE_Message_Block
*mb
= 0,
182 unsigned int size
= 0);
184 virtual void read (JAWS_IO_Handler
*ioh
,
185 ACE_Message_Block
*mb
,
188 virtual void transmit_file (JAWS_IO_Handler
*ioh
,
191 unsigned int header_size
,
193 unsigned int trailer_size
);
195 virtual void transmit_file (JAWS_IO_Handler
*ioh
,
196 const char *filename
,
198 unsigned int header_size
,
200 unsigned int trailer_size
);
202 virtual void receive_file (JAWS_IO_Handler
*ioh
,
203 const char *filename
,
205 unsigned int initial_data_length
,
206 unsigned int entire_length
);
208 virtual void send_confirmation_message (JAWS_IO_Handler
*ioh
,
210 unsigned int length
);
212 virtual void send_error_message (JAWS_IO_Handler
*ioh
,
214 unsigned int length
);
216 #ifdef ACE_LYNXOS_MAJOR
219 #endif /* ERROR_MESSAGE */
220 #endif /* ACE_LYNXOS_MAJOR */
230 virtual void send_message (JAWS_IO_Handler
*ioh
,
236 typedef ACE_Singleton
<JAWS_Asynch_IO
, ACE_SYNCH_MUTEX
>
237 JAWS_Asynch_IO_Singleton
;
240 * @class JAWS_Asynch2_IO
241 This version of Asynch_IO has a do nothing accept() implementation.
243 class JAWS_Export JAWS_Asynch2_IO
: public JAWS_Asynch_IO
247 virtual void accept (JAWS_IO_Handler
*ioh
,
248 ACE_Message_Block
*mb
= 0,
249 unsigned int size
= 0);
253 typedef ACE_Singleton
<JAWS_Asynch2_IO
, ACE_SYNCH_MUTEX
>
254 JAWS_Asynch2_IO_Singleton
;
256 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
258 #endif /* JAWS_IO_H */