("help", "produce help message")
("duration", po::value<int>(),
"number of seconds for server to exist")
+ ("port", po::value< std::vector<std::string> >(), "listener port")
;
+ po::positional_options_description p;
+ p.add("port", -1);
+
po::variables_map vm;
- po::store(po::parse_command_line(argc, argv, desc), vm);
+ po::store(po::command_line_parser(argc, argv).
+ options(desc).positional(p).run(), vm);
po::notify(vm);
if (vm.count("help")) {
return 1;
}
+ if (vm.count("port"))
{
+ std::vector<std::string> ports =
+ vm["port"].as< std::vector<std::string> >();
+
+ for (size_t i = 0; i<ports.size(); i++)
+ std::cout << "port " << i << " " << ports[i] << "\n";
+
yp2::RouterChain router;
// put in frontend first
yp2::FilterFrontendNet filter_front;
- filter_front.listen_address() = "tcp:@:9999";
+ filter_front.ports() = ports;
// 0=no time, >0 timeout in seconds
if (vm.count("duration")) {
- filter_front.listen_duration() =
- vm["duration"].as<int>();
+ filter_front.listen_duration() = vm["duration"].as<int>();
}
router.rule(filter_front);
yazpp_1::IPDU_Observer *ZAssocServer::sessionNotify(yazpp_1::IPDU_Observable
*the_PDU_Observable, int fd)
{
- ZAssocServerChild *my = new ZAssocServerChild(the_PDU_Observable, m_thread_pool_observer,
- m_package);
+ ZAssocServerChild *my =
+ new ZAssocServerChild(the_PDU_Observable, m_thread_pool_observer,
+ m_package);
return my;
}
FilterFrontendNet::FilterFrontendNet()
{
m_no_threads = 5;
- m_listen_address = "@:9001";
m_listen_duration = 0;
}
if (m_listen_duration)
tt = new My_Timer_Thread(&mySocketManager, m_listen_duration);
- yazpp_1::PDU_Assoc *my_PDU_Assoc =
- new yazpp_1::PDU_Assoc(&mySocketManager);
-
ThreadPoolSocketObserver threadPool(&mySocketManager, m_no_threads);
- ZAssocServer z(my_PDU_Assoc, &threadPool, &package);
- z.server(m_listen_address.c_str());
+ ZAssocServer **az = new ZAssocServer *[m_ports.size()];
+
+ // Create ZAssocServer for each port
+ size_t i;
+ for (i = 0; i<m_ports.size(); i++)
+ {
+ // create a PDU assoc object (one per ZAssocServer)
+ yazpp_1::PDU_Assoc *as = new yazpp_1::PDU_Assoc(&mySocketManager);
+ // create ZAssoc with PDU Assoc
+ az[i] = new ZAssocServer(as, &threadPool, &package);
+ az[i]->server(m_ports[i].c_str());
+ }
while (mySocketManager.processEvent() > 0)
{
if (tt && tt->timeout())
break;
}
+ for (i = 0; i<m_ports.size(); i++)
+ delete az[i];
+
+ delete [] az;
delete tt;
}
-std::string &FilterFrontendNet::listen_address()
+std::vector<std::string> &FilterFrontendNet::ports()
{
- return m_listen_address;
+ return m_ports;
}
int &FilterFrontendNet::listen_duration()
#define FILTER_FRONEND_NET_HPP
#include <stdexcept>
+#include <vector>
#include "filter.hpp"
void process(yp2::Package & package) const;
private:
int m_no_threads;
- std::string m_listen_address;
+ std::vector<std::string> m_ports;
int m_listen_duration;
public:
/// set function - left val in assignment
- std::string & listen_address();
+ std::vector<std::string> &ports();
int &listen_duration();
};
}
// put in frontend first
yp2::FilterFrontendNet filter_front;
- filter_front.listen_address() = "unix:socket";
+
+ std::vector <std::string> ports;
+ ports.insert(ports.begin(), "unix:socket");
+ filter_front.ports() = ports;
filter_front.listen_duration() = 1; // listen a short time only
router.rule(filter_front);