当前位置: 首页>>代码示例>>C++>>正文


C++ SocketPtr::signal_data_received方法代码示例

本文整理汇总了C++中SocketPtr::signal_data_received方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketPtr::signal_data_received方法的具体用法?C++ SocketPtr::signal_data_received怎么用?C++ SocketPtr::signal_data_received使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SocketPtr的用法示例。


在下文中一共展示了SocketPtr::signal_data_received方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void
DataServer::on_client_created( const SocketPtr &in_client ) {
    in_client->signal_data_received().connect( boost::bind(
                    std::mem_fn(&DataServer::on_data_received),
                    this, _1, _2));
    m_server->signal_client_created().connect( boost::bind(
                        std::mem_fn( &DataServer::on_client_disconnect),
                        this, _1 ));
}
开发者ID:Tushar-Naik,项目名称:hpcl,代码行数:9,代码来源:data_server.cpp

示例2: main

int main() 
try {
    SocketFactoryPtr factory = SocketFactory::create_factory();
    SocketPtr socket = factory->create_socket( true );
    socket->signal_data_received().connect( handle_data );
    socket->signal_remote_disconnect().connect( handle_stop );
    socket->connect_to_server( "127.0.0.1", 1024 );
    while( true )
    {
        {
            std::lock_guard<std::mutex> l(g_stop_mutex);
            if( g_stop )
            {
                socket->shutdown();
                break;
            }
        }
        std::string msg;
        std::cout<<"say? ";
        getline( std::cin, msg );
        if( "QUIT" == msg )
        {
            std::lock_guard<std::mutex> l(g_stop_mutex);
            g_stop = true;
            socket->shutdown();
        }
        else if( "STOPLISTENER" == msg )
        {
            send_data( socket, msg );
            socket->shutdown();
            std::lock_guard<std::mutex> l(g_stop_mutex);
            g_stop = true;
        }
        else
        {
            send_data( socket, msg );
        }
    }
    return 0;
}
catch( boost::exception &error ) {
    int const *errorNo
                = boost::get_error_info<boost::errinfo_errno>( error );
    std::cerr<<"Error occurred [" <<strerror(*errorNo) <<"]"<<std::endl;
    return -1;
}
catch( std::exception &e ) {
    std::cerr<<"Error occurred [" <<e.what() <<"]"<<std::endl;
    return -1;
}
开发者ID:Tushar-Naik,项目名称:hpcl,代码行数:50,代码来源:client.cpp

示例3:

void
RemoteLogServer::on_create( const SocketPtr &in_socket ) {
    in_socket->signal_data_received().connect( boost::bind(
                std::mem_fn( &RemoteLogServer::on_log_received), this, _1, _2));
}
开发者ID:Tushar-Naik,项目名称:hpcl,代码行数:5,代码来源:remote_log_server.cpp


注:本文中的SocketPtr::signal_data_received方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。