Ejemplo n.º 1
0
OlsrEventClient::OlsrEventClient ( boost::asio::io_service& io_service, tcp::endpoint& endpoint )
        : m_io_service ( io_service ), m_tcpConnection ( TcpConnectionPtr ( new TcpConnection ( io_service ) ) )
{
    // Asynchronous connection to server
    tcp::socket& sock = m_tcpConnection->socket();
    sock.async_connect ( endpoint,
                         boost::bind ( &OlsrEventClient::handleConnect, this,
                                       boost::asio::placeholders::error )
                       );
}
Ejemplo n.º 2
0
 void TcpServer::NewConnection(int accept_fd,Ip4Addr local,Ip4Addr peer)
 {
     TcpConnectionPtr connection=TcpConnectionPtr(new TcpConnection(loop_));
     if (readcb_)
         connection->SetReadCb(readcb_);
     if (writecb_)
         connection->SetWriteCb(writecb_);
     if (closecb_)
         connection->SetCloseCb(closecb_);
     
     connection->Register(loop_, accept_fd,local,peer);
     tcpConnectionFd_[accept_fd]=connection;    //添加Tcp连接与accept套接字至映射队列        
 }
Ejemplo n.º 3
0
 //
 //TCP Client模块
 //新建TCP客户端
 //
 void TcpClient::RunClient()
 {
     this->Bind();
     this->HandleConnect();
     client_channel_->SetEvent(EVFILT_READ);
     loop_->UpdateChannel(client_channel_);
     
     TcpConnectionPtr conn=TcpConnectionPtr(new TcpConnection(loop_));
     if (readcb_)
     {
         conn->SetReadCb(readcb_);
     }
     if (writecb_) {
         conn->SetWriteCb(writecb_);
     }
     
 }
Ejemplo n.º 4
0
OlsrEventClient::OlsrEventClient (boost::asio::io_service& io_service)
        : m_io_service ( io_service ), m_tcpConnection ( TcpConnectionPtr ( new TcpConnection ( io_service ) ) )
{
}