1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
// $Id: IO_Acceptor.cpp 91671 2010-09-08 18:39:23Z johnnyw $
#include "JAWS/Data_Block.h"
#include "JAWS/IO_Acceptor.h"
#include "ace/OS_NS_sys_socket.h"
JAWS_IO_Acceptor::JAWS_IO_Acceptor (void)
{
}
JAWS_IO_Acceptor::~JAWS_IO_Acceptor (void)
{
}
int
JAWS_IO_Acceptor::open (const ACE_INET_Addr &, int)
{
return -1;
}
int
JAWS_IO_Acceptor::open (const ACE_HANDLE &)
{
return -1;
}
void
JAWS_IO_Acceptor::close (void)
{
}
int
JAWS_IO_Acceptor::accept (ACE_SOCK_Stream &, ACE_Addr *, ACE_Time_Value *,
int, int) const
{
return -1;
}
int
JAWS_IO_Acceptor::accept (size_t, const void *)
{
return -1;
}
ACE_HANDLE
JAWS_IO_Acceptor::get_handle (void)
{
return ACE_INVALID_HANDLE;
}
int
JAWS_IO_Synch_Acceptor::open (const ACE_INET_Addr &local_sap, int backlog)
{
return this->acceptor_.open (local_sap, 1, PF_INET, backlog);
}
int
JAWS_IO_Synch_Acceptor::open (const ACE_HANDLE &socket)
{
ACE_HANDLE handle = this->acceptor_.get_handle ();
if (handle == socket)
return 0;
if (handle != ACE_INVALID_HANDLE)
ACE_OS::closesocket (this->acceptor_.get_handle ());
this->acceptor_.set_handle (socket);
return 0;
}
int
JAWS_IO_Synch_Acceptor::accept (ACE_SOCK_Stream &new_stream,
ACE_Addr *remote_addr,
ACE_Time_Value *timeout,
int restart,
int reset_new_handle) const
{
return this->acceptor_.accept (new_stream, remote_addr, timeout,
restart, reset_new_handle);
}
int
JAWS_IO_Synch_Acceptor::accept (size_t, const void *)
{
return -1;
}
ACE_HANDLE
JAWS_IO_Synch_Acceptor::get_handle (void)
{
return this->acceptor_.get_handle ();
}
JAWS_IO_Asynch_Acceptor::JAWS_IO_Asynch_Acceptor (void)
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
: acceptor_ (*(new ACE_Asynch_Acceptor<JAWS_Asynch_Handler>)),
acceptor_ptr_ (&acceptor_)
#endif
{
}
JAWS_IO_Asynch_Acceptor::~JAWS_IO_Asynch_Acceptor (void)
{
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
delete this->acceptor_ptr_;
this->acceptor_ptr_ = 0;
#endif
}
int
JAWS_IO_Asynch_Acceptor::open (const ACE_INET_Addr &address, int backlog)
{
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
// Tell the acceptor to listen on this->port_, which sets up an
// asynchronous I/O request to the OS.
return this->acceptor_.open (address,
JAWS_Data_Block::JAWS_DATA_BLOCK_SIZE,
1,
backlog,
1,
0,
0,
0,
0);
#else
ACE_UNUSED_ARG (address);
ACE_UNUSED_ARG (backlog);
return -1;
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
}
int
JAWS_IO_Asynch_Acceptor::open (const ACE_HANDLE &socket)
{
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
ACE_HANDLE handle = this->handle_;
if (handle == socket)
return 0;
if (handle != ACE_INVALID_HANDLE)
ACE_OS::closesocket (handle);
this->handle_ = socket;
return 0;
#else
ACE_UNUSED_ARG (socket);
return -1;
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
}
int
JAWS_IO_Asynch_Acceptor::accept (size_t bytes_to_read, const void *act)
{
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
return this->acceptor_.accept (bytes_to_read, act);
#else
ACE_UNUSED_ARG (bytes_to_read);
ACE_UNUSED_ARG (act);
return -1;
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
}
int
JAWS_IO_Asynch_Acceptor::accept (ACE_SOCK_Stream &, ACE_Addr *,
ACE_Time_Value *, int, int) const
{
return -1;
}
ACE_HANDLE
JAWS_IO_Asynch_Acceptor::get_handle (void)
{
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
return this->acceptor_.get_handle ();
#else
return ACE_INVALID_HANDLE;
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
}
void
JAWS_IO_Asynch_Acceptor::close (void)
{
#if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
delete this->acceptor_ptr_;
this->acceptor_ptr_ = 0;
#endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
}
|