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
|
#include "orbsvcs/Log_Macros.h"
#include "orbsvcs/Log_Macros.h"
#include "ace/INET_Addr.h"
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
template <ACE_PEER_STREAM_1>
int ConnectionAcceptHandler<ACE_PEER_STREAM_2>::open (void * acceptor)
{
ACE_TRACE("ConnectionAcceptHandler::open\n");
ACE_INET_Addr addr;
if (this->peer ().get_remote_addr (addr) == -1)
return -1;
reactor_ = static_cast<ACE_Service_Object*> (acceptor)->reactor();
if (reactor_->register_handler (this,
ACE_Event_Handler::READ_MASK) == -1)
ORBSVCS_ERROR_RETURN ((LM_ERROR,
"(%P|%t) can't register with reactor\n"),
-1);
ORBSVCS_DEBUG ((LM_DEBUG,
"(%P|%t) connected with %s\n",
addr.get_host_name ()));
return 0;
}
template <ACE_PEER_STREAM_1>
void ConnectionAcceptHandler<ACE_PEER_STREAM_2>::destroy ()
{
// Remove ourselves from the reactor
reactor_->remove_handler
(this,
ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL);
// Shut down the connection to the client.
this->peer ().close ();
// Free our memory.
delete this;
}
// If somebody doesn't like us, they will close() us. Actually, if
// our open() method returns -1, the Acceptor<> will invoke close()
// on us for cleanup.
template <ACE_PEER_STREAM_1>
int ConnectionAcceptHandler<ACE_PEER_STREAM_2>::close (u_long flags)
{
ACE_UNUSED_ARG (flags);
this->destroy ();
return 0;
}
template <ACE_PEER_STREAM_1>
int ConnectionAcceptHandler<ACE_PEER_STREAM_2>::handle_input (ACE_HANDLE)
{
char buf[8];
if (this->peer().recv(buf, sizeof(buf)))
return -1;
return 0;
}
// Clean ourselves up when handle_input() (or handle_timer()) returns -1
template <ACE_PEER_STREAM_1>
int ConnectionAcceptHandler<ACE_PEER_STREAM_2>::handle_close (ACE_HANDLE,
ACE_Reactor_Mask)
{
this->destroy ();
return 0;
}
template <ACE_PEER_STREAM_1>
int ConnectionDetectHandler<ACE_PEER_STREAM_2>::handle_close (ACE_HANDLE,
ACE_Reactor_Mask)
{
ACE_TRACE("ConnectionDetectHandler::handle_close\n");
this->close();
return 0;
}
template <ACE_PEER_STREAM_1>
int ConnectionDetectHandler<ACE_PEER_STREAM_2>::close (u_long )
{
if (listener_)
listener_->connection_closed();
delete this;
return 0;
}
TAO_END_VERSIONED_NAMESPACE_DECL
|