doc: fix incomplete ping session initialization

Thanks @nopnop2002 for reporting this issue.
Closes https://github.com/espressif/esp-idf/issues/4648
This commit is contained in:
morris 2020-01-20 21:03:58 +08:00
parent e0fe136bf9
commit 1c710a1b31

View File

@ -65,6 +65,11 @@ Example method to create a new ping session and register callbacks:
void initialize_ping()
{
/* convert URL to IP address */
ip_addr_t target_addr;
struct addrinfo hint;
struct addrinfo *res = NULL;
memset(&hint, 0, sizeof(hint));
memset(&target_addr, 0, sizeof(target_addr));
getaddrinfo("www.espressif.com", NULL, &hint, &res) == 0);
struct in_addr addr4 = ((struct sockaddr_in *) (res->ai_addr))->sin_addr;
inet_addr_to_ip4addr(ip_2_ip4(&target_addr), &addr4);