/* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ tb_aicp_dns_ref_t tb_aicp_dns_init(tb_aicp_ref_t aicp) { // check tb_assert_and_check_return_val(aicp, tb_null); // done tb_bool_t ok = tb_false; tb_aicp_dns_impl_t* impl = tb_null; do { // make impl impl = tb_malloc0_type(tb_aicp_dns_impl_t); tb_assert_and_check_break(impl); // init aicp impl->aicp = aicp; // ok ok = tb_true; } while (0); // failed? if (!ok) { // exit it if (impl) tb_aicp_dns_exit((tb_aicp_dns_ref_t)impl); impl = tb_null; } // ok? return (tb_aicp_dns_ref_t)impl; }
/* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ static tb_void_t tb_demo_sock_dns_done_func(tb_aicp_dns_ref_t dns, tb_char_t const* host, tb_ipv4_t const* addr, tb_cpointer_t priv) { // check tb_assert_and_check_return(dns); // the aicp tb_aicp_ref_t aicp = tb_aicp_dns_aicp(dns); tb_assert_and_check_return(aicp); // addr ok? if (addr) { // trace tb_trace_i("dns[%s]: %u.%u.%u.%u", host, addr->u8[0], addr->u8[1], addr->u8[2], addr->u8[3]); } // timeout or failed? else { // trace tb_trace_i("dns[%s]: failed", host); } // exit addr if (dns) tb_aicp_dns_exit(dns); // kill aicp tb_aicp_kill(aicp); }