added OnConnect Callback
[anytun.git] / src / syncTcpConnection.cpp
blobdbd9ac069d28216067fbf79e36c5334e660da1d6
1 #include "syncTcpConnection.h"
2 #include <boost/bind.hpp>
3 #include <asio.hpp>
5 #include <sstream>
6 #include <iostream>
7 #include <string>
8 #include "routingTable.h"
9 #include "rtpSessionTable.h"
10 #include <boost/archive/text_oarchive.hpp>
11 #include <boost/archive/text_iarchive.hpp>
14 #include "syncCommand.h"
15 #include "buffer.h"
17 asio::ip::tcp::socket& SyncTcpConnection::socket()
19 return socket_;
22 void SyncTcpConnection::start()
24 onConnect(this);
27 void SyncTcpConnection::Send(std::string message)
29 asio::async_write(socket_, asio::buffer(message),
30 boost::bind(&SyncTcpConnection::handle_write, shared_from_this(),
31 asio::placeholders::error,
32 asio::placeholders::bytes_transferred));
34 SyncTcpConnection::SyncTcpConnection(asio::io_service& io_service)
35 : socket_(io_service)
39 void SyncTcpConnection::handle_write(const asio::error_code& /*error*/,
40 size_t /*bytes_transferred*/)