1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #include <anna/core/tracing/Logger.hpp>
10 #include <anna/core/functions.hpp>
11 #include <anna/core/mt/Guard.hpp>
13 #include <anna/xml/Node.hpp>
14 #include <anna/xml/Attribute.hpp>
16 #include <anna/comm/Communicator.hpp>
17 #include <anna/comm/internal/BinderSocket.hpp>
19 #include <anna/comm/handler/BinderSocket.hpp>
24 //-----------------------------------------------------------------------
25 // La apertura de cierre de este Socket se hace desde el comm::Socket.
26 //-----------------------------------------------------------------------
27 void comm::handler::BinderSocket::initialize()
28 throw(RuntimeException) {
29 if(a_binderSocket == NULL) {
30 string msg(asString());
31 msg += " | comm::BinderSocket was not established";
32 throw RuntimeException(msg, ANNA_FILE_LOCATION);
35 setfd(a_binderSocket->getfd());
38 //---------------------------------------------------------------------------------------
39 // Cuando detecta actividad lo unico que hace es invocar al metodo del BinderSocket
40 // que deberia estar esperando la respuesta para saber el 'fd' del nuevo socket
41 // compartido que va a crear.
42 //---------------------------------------------------------------------------------------
43 void comm::handler::BinderSocket::apply()
44 throw(RuntimeException) {
45 Guard guard(a_binderSocket);
46 a_binderSocket->responseBind();
49 void comm::handler::BinderSocket::finalize()
51 if(a_binderSocket == NULL)
54 Guard guard(a_binderSocket);
55 a_binderSocket->close();
56 a_binderSocket = NULL;
59 string comm::handler::BinderSocket::asString() const
61 string result("comm::handler::BinderSocket { ");
62 result += comm::Handler::asString();
64 result += functions::asString(a_binderSocket);
65 return result += " }";
68 xml::Node* comm::handler::BinderSocket::asXML(xml::Node* parent) const
70 xml::Node* result = parent->createChild("comm.handler.BinderSocket");
71 comm::Handler::asAttribute(result);
74 a_binderSocket->asXML(result);