added SyncRtpCommand
[anytun.git] / syncSocket.cpp
blob6681ba342f852824ac36322e972e5ff52e022405
1 #include <sstream>
2 #include <iostream>
3 #include <string>
4 #include "routingTable.h"
5 #include <boost/archive/text_oarchive.hpp>
6 #include <boost/archive/text_iarchive.hpp>
9 //#include "connectionParam.h"
10 #include "Sockets/Utility.h"
11 #include "syncSocket.h"
12 #include "syncCommand.h"
13 #include "buffer.h"
14 //#include "log.h"
16 SyncSocket::SyncSocket(ISocketHandler& h,ConnectionList & cl)
17 :TcpSocket(h),cl_(cl)
19 SetConnectTimeout(12);
24 void SyncSocket::OnAccept()
26 // Send( Utility::GetLocalHostname() + "\n");
27 // Send( Utility::GetLocalAddress() + "\n");
28 // Send("Number of sockets in list : " + Utility::l2string(Handler().GetCount()) + "\n");
29 // Send("\n");
30 //TODO Locking here
31 ConnectionMap::iterator cit = cl_.getBeginUnlocked();
32 for (;cit!=cl_.getEndUnlocked();++cit)
34 std::ostringstream sout;
35 boost::archive::text_oarchive oa(sout);
36 const SyncCommand scom(cl_,cit->first);
37 oa << scom;
38 std::stringstream lengthout;
39 lengthout << std::setw(5) << std::setfill('0') << sout.str().size()<< ' ';
40 Send(lengthout.str());
41 Send(sout.str());
43 //TODO Locking here
44 RoutingMap::iterator it = gRoutingTable.getBeginUnlocked();
45 for (;it!=gRoutingTable.getEndUnlocked();++it)
47 NetworkPrefix tmp(it->first);
48 std::ostringstream sout;
49 boost::archive::text_oarchive oa(sout);
50 const SyncCommand scom(tmp);
51 oa << scom;
52 std::stringstream lengthout;
53 lengthout << std::setw(5) << std::setfill('0') << sout.str().size()<< ' ';
54 Send(lengthout.str());
55 Send(sout.str());
59 //void StatusSocket::InitSSLServer()
60 //{
61 // InitializeContext("server.pem", "keypwd", SSLv23_method());
62 //}
65 //void StatusSocket::Init()
66 //{
67 // EnableSSL();
68 //}