Hi, I'm making a simple code to check whether a user provided IP is
bindable in any UDP port (so port 0), so basically I run this code
(some error checking is missing yet):


----------------------------------------------
void checkIP(char* ip, int family) {

uv_loop_t loop;
uv_udp_t udp_socket;
struct sockaddr_storage bind_addr;
int err = 0;

uv_loop_init(&loop);
uv_udp_init(&loop, &udp_socket);

switch(family) {
  case AF_INET:
    uv_ip4_addr(ip, 0, (struct sockaddr_in*)&bind_addr);
    break;
  case AF_INET6:
    uv_ip6_addr(ip, 0, (struct sockaddr_in6*)&bind_addr);
    break;
}

err = uv_udp_bind(&udp_socket, (const struct sockaddr*)&bind_addr, 0);
uv_close((uv_handle_t*)&udp_socket, (uv_close_cb)on_close);
uv_loop_close(&loop);

if (err)
  lalala("uv_udp_bind() failed: %s", uv_strerror(err));
}

}

-----------------------------------------------


Note that I don't even call uv_run(). Is it guaranteed that
uv_udp_bind() would return error in case of giving it an address in
which the host cannot bind?

Thanks a lot.


-- 
Iñaki Baz Castillo
<[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to