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


C++ SocketClient::connect方法代码示例

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


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

示例1: addr

    int  open_connection        (const String &config, const String &display)
    {
        SocketAddress addr (scim_get_default_panel_socket_address (display));

        if (m_socket.is_connected ()) close_connection ();

        bool ret;
        int count = 0;

        // Try three times.
        while (1) {
            if ((ret = m_socket.connect (addr)) == false) {
                scim_usleep (100000);
                launch_panel (config, display);
                for (int i = 0; i < 200; ++i) {
                    if (m_socket.connect (addr)) {
                        ret = true;
                        break;
                    }
                    scim_usleep (100000);
                }
            }
 
            if (ret && scim_socket_open_connection (m_socket_magic_key, String ("FrontEnd"), String ("Panel"), m_socket, m_socket_timeout))
                break;

            m_socket.close ();

            if (count++ >= 3) break;

            scim_usleep (100000);
        }

        return m_socket.get_id ();
    }
开发者ID:dancor,项目名称:scim,代码行数:35,代码来源:scim_panel_client.cpp

示例2: menuCloseCallback

void MainLayer::menuCloseCallback(Object* pSender)
{
	SocketClient* socketClient = SocketClient::createSocketClient("127.0.0.1",12345);
	socketClient->retain();
	SocketMgr::set(socketClient);

	socketClient = SocketMgr::get();

	auto callback = std::bind(&MainLayer::onLoginResponse,this,std::placeholders::_1);
	socketClient->registCallbackT<LoginResponse>(1,callback);

	if (socketClient->connect())
	{
		LoginRequest* loginRequestMessage = new LoginRequest();
		loginRequestMessage->set_username("cmzx3444");
		loginRequestMessage->set_password("123456");
		socketClient->send(loginRequestMessage);

		loginRequestMessage = new LoginRequest();
		loginRequestMessage->set_username("cmzx3444");
		loginRequestMessage->set_password("123456");
		socketClient->send(loginRequestMessage);

		loginRequestMessage = new LoginRequest();
		loginRequestMessage->set_username("cmzx3444");
		loginRequestMessage->set_password("123456");
		socketClient->send(loginRequestMessage);

		loginRequestMessage = new LoginRequest();
		loginRequestMessage->set_username("cmzx3444");
		loginRequestMessage->set_password("123456");
		socketClient->send(loginRequestMessage);
	}
	else
	{
		socketClient->release();
	}

    Director::getInstance()->end();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    exit(0);
#endif
}
开发者ID:liangzhimy,项目名称:ForeverClient,代码行数:44,代码来源:MainLayer.cpp

示例3: check_socket_frontend

bool check_socket_frontend ()
{
    SocketAddress address;
    SocketClient client;

    uint32 magic;

    address.set_address (scim_get_default_socket_frontend_address ());

    if (!client.connect (address))
        return false;

    if (!scim_socket_open_connection (magic,
                                      String ("ConnectionTester"),
                                      String ("SocketFrontEnd"),
                                      client,
                                      1000)) {
        return false;
    }

    return true;
}
开发者ID:dancor,项目名称:scim,代码行数:22,代码来源:scim.cpp


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