1 #include "JAWS/Data_Block.h"
2 #include "JAWS/IO_Acceptor.h"
4 #include "ace/OS_NS_sys_socket.h"
7 JAWS_IO_Acceptor::JAWS_IO_Acceptor ()
11 JAWS_IO_Acceptor::~JAWS_IO_Acceptor ()
16 JAWS_IO_Acceptor::open (const ACE_INET_Addr
&, int)
22 JAWS_IO_Acceptor::open (const ACE_HANDLE
&)
28 JAWS_IO_Acceptor::close ()
33 JAWS_IO_Acceptor::accept (ACE_SOCK_Stream
&, ACE_Addr
*, ACE_Time_Value
*,
40 JAWS_IO_Acceptor::accept (size_t, const void *)
46 JAWS_IO_Acceptor::get_handle ()
48 return ACE_INVALID_HANDLE
;
52 JAWS_IO_Synch_Acceptor::open (const ACE_INET_Addr
&local_sap
, int backlog
)
54 return this->acceptor_
.open (local_sap
, 1, PF_INET
, backlog
);
58 JAWS_IO_Synch_Acceptor::open (const ACE_HANDLE
&socket
)
60 ACE_HANDLE handle
= this->acceptor_
.get_handle ();
64 if (handle
!= ACE_INVALID_HANDLE
)
65 ACE_OS::closesocket (this->acceptor_
.get_handle ());
66 this->acceptor_
.set_handle (socket
);
72 JAWS_IO_Synch_Acceptor::accept (ACE_SOCK_Stream
&new_stream
,
73 ACE_Addr
*remote_addr
,
74 ACE_Time_Value
*timeout
,
76 int reset_new_handle
) const
78 return this->acceptor_
.accept (new_stream
, remote_addr
, timeout
,
79 restart
, reset_new_handle
);
83 JAWS_IO_Synch_Acceptor::accept (size_t, const void *)
89 JAWS_IO_Synch_Acceptor::get_handle ()
91 return this->acceptor_
.get_handle ();
95 JAWS_IO_Asynch_Acceptor::JAWS_IO_Asynch_Acceptor ()
96 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
97 : acceptor_ (*(new ACE_Asynch_Acceptor
<JAWS_Asynch_Handler
>)),
98 acceptor_ptr_ (&acceptor_
)
103 JAWS_IO_Asynch_Acceptor::~JAWS_IO_Asynch_Acceptor ()
105 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
106 delete this->acceptor_ptr_
;
107 this->acceptor_ptr_
= 0;
112 JAWS_IO_Asynch_Acceptor::open (const ACE_INET_Addr
&address
, int backlog
)
114 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
115 // Tell the acceptor to listen on this->port_, which sets up an
116 // asynchronous I/O request to the OS.
118 return this->acceptor_
.open (address
,
119 JAWS_Data_Block::JAWS_DATA_BLOCK_SIZE
,
129 ACE_UNUSED_ARG (address
);
130 ACE_UNUSED_ARG (backlog
);
132 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
136 JAWS_IO_Asynch_Acceptor::open (const ACE_HANDLE
&socket
)
138 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
139 ACE_HANDLE handle
= this->handle_
;
140 if (handle
== socket
)
143 if (handle
!= ACE_INVALID_HANDLE
)
144 ACE_OS::closesocket (handle
);
145 this->handle_
= socket
;
149 ACE_UNUSED_ARG (socket
);
151 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
155 JAWS_IO_Asynch_Acceptor::accept (size_t bytes_to_read
, const void *act
)
157 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
158 return this->acceptor_
.accept (bytes_to_read
, act
);
160 ACE_UNUSED_ARG (bytes_to_read
);
161 ACE_UNUSED_ARG (act
);
163 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
167 JAWS_IO_Asynch_Acceptor::accept (ACE_SOCK_Stream
&, ACE_Addr
*,
168 ACE_Time_Value
*, int, int) const
174 JAWS_IO_Asynch_Acceptor::get_handle ()
176 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
177 return this->acceptor_
.get_handle ();
179 return ACE_INVALID_HANDLE
;
180 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
185 JAWS_IO_Asynch_Acceptor::close ()
187 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
188 delete this->acceptor_ptr_
;
189 this->acceptor_ptr_
= 0;
190 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */