Merge branch 'master' into jwi-bcc64xsingletonwarning
[ACE_TAO.git] / ACE / apps / JAWS2 / JAWS / IO_Acceptor.cpp
blobe4ee96609eb9854db0a7aac35e27ece530384bbc
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 ()
15 int
16 JAWS_IO_Acceptor::open (const ACE_INET_Addr &, int)
18 return -1;
21 int
22 JAWS_IO_Acceptor::open (const ACE_HANDLE &)
24 return -1;
27 void
28 JAWS_IO_Acceptor::close ()
32 int
33 JAWS_IO_Acceptor::accept (ACE_SOCK_Stream &, ACE_Addr *, ACE_Time_Value *,
34 int, int) const
36 return -1;
39 int
40 JAWS_IO_Acceptor::accept (size_t, const void *)
42 return -1;
45 ACE_HANDLE
46 JAWS_IO_Acceptor::get_handle ()
48 return ACE_INVALID_HANDLE;
51 int
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);
57 int
58 JAWS_IO_Synch_Acceptor::open (const ACE_HANDLE &socket)
60 ACE_HANDLE handle = this->acceptor_.get_handle ();
61 if (handle == socket)
62 return 0;
64 if (handle != ACE_INVALID_HANDLE)
65 ACE_OS::closesocket (this->acceptor_.get_handle ());
66 this->acceptor_.set_handle (socket);
68 return 0;
71 int
72 JAWS_IO_Synch_Acceptor::accept (ACE_SOCK_Stream &new_stream,
73 ACE_Addr *remote_addr,
74 ACE_Time_Value *timeout,
75 int restart,
76 int reset_new_handle) const
78 return this->acceptor_.accept (new_stream, remote_addr, timeout,
79 restart, reset_new_handle);
82 int
83 JAWS_IO_Synch_Acceptor::accept (size_t, const void *)
85 return -1;
88 ACE_HANDLE
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_)
99 #endif
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;
108 #endif
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,
121 backlog,
128 #else
129 ACE_UNUSED_ARG (address);
130 ACE_UNUSED_ARG (backlog);
131 return -1;
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)
141 return 0;
143 if (handle != ACE_INVALID_HANDLE)
144 ACE_OS::closesocket (handle);
145 this->handle_ = socket;
147 return 0;
148 #else
149 ACE_UNUSED_ARG (socket);
150 return -1;
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);
159 #else
160 ACE_UNUSED_ARG (bytes_to_read);
161 ACE_UNUSED_ARG (act);
162 return -1;
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
170 return -1;
173 ACE_HANDLE
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 ();
178 #else
179 return ACE_INVALID_HANDLE;
180 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
184 void
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 */