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


C++ IpAddress::resolve_name方法代码示例

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


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

示例1: connect

YETI_Result HttpTcpConnector::connect(const HttpUrl & url,
                                      HttpClient & client,
                                      const HttpProxyAddress * proxy,
                                      bool reuse, HttpClient::Connection *& connection)
{
    connection = NULL;
    const char * server_hostname;
    YETI_UInt16 server_port;
    if (proxy) {
        server_hostname = (const char *)proxy->get_hostname();
        server_port = proxy->get_port();
    } else {
        server_hostname = (const char *)url.get_host();
        server_port = url.get_port();
    }

    IpAddress address;
    YETI_CHECK_FINE(address.resolve_name(server_hostname, client.get_config().m_name_resolver_timeout_));
    YETI_LOG_FINE_2("TCP connector will connect to %s : %d", server_hostname, server_port);
    TcpClientSocket * tcp_socket = new TcpClientSocket();
    SocketReference socket(tcp_socket, true);
    tcp_socket->set_read_timeout(client.get_config().m_io_timeout_);
    tcp_socket->set_write_timeout(client.get_config().m_io_timeout_);
    SocketAddress socket_address(address, server_port);
    YETI_CHECK_FINE(tcp_socket->connect(socket_address, client.get_config().m_connection_timeout_));

    HttpSimpleConnection * _connection = new HttpSimpleConnection();
    _connection->m_socket_ = socket;
    connection = _connection;
    tcp_socket->get_input_stream(_connection->m_inputstream_);
    tcp_socket->get_output_stream(_connection->m_outputstream_);

    return YETI_SUCCESS;
}
开发者ID:xindawndev,项目名称:cxl-yeti,代码行数:34,代码来源:YetiHttp.cpp

示例2: my_send

int my_send()
{
    printf("==== Send\n");

    char * msg = "hello";
    UdpSocket sender;
    DataBuffer buffer(1024);
    buffer.set_data_size(1024);
    buffer.set_data((YETI_Byte *)msg, strlen(msg));
    IpAddress address;
    address.resolve_name("localhost");
    SocketAddress socket_address(address, 9123);
    YETI_Result result = sender.send(buffer, &socket_address);
    if (YETI_FAILED(result)) {
        fprintf(stderr, "send() failed (%d)\n", result);
        return result;
    }
    return 0;
}
开发者ID:xindawndev,项目名称:cxl-yeti,代码行数:19,代码来源:YetiUdpTest.cpp


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