-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 07/21/2014 10:57 AM, Iñaki Baz Castillo wrote:
> 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.
>
>
Yes, bind happens immediately, it's not blocking.
- --
Saúl Ibarra Corretgé
bettercallsaghul.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Icedove - http://www.enigmail.net/
iQIcBAEBAgAGBQJTzNtQAAoJEEEOVVOum8BZTM4P/i0UQa9DCq9hoR9CTQO5F+tJ
PPd/qckb9zKhr5f+xU06yaylSylZv4d19INmp32CL8tJhhsxT82l/39EGbHGbLln
Z3RDyJB96xcvv7FBPV4zlJJznRDTFmqv+ki144bCFH9oTs0gW+tDZ75X6MIJmk9+
3xFsP3VDe+HOrwbDiZQBp1xGmtpmK5T+3Vz4dsy84tlK08F60RDQ1xbIX3tl5+mb
KXCzK6SQZuB2xgGSbVUtcPV2VkTtrwL6cP1DWAUGOShVThdwZ9GErW//oowTtkGo
yYhW9JfTSGV+Odl0tbAyOVbsc2YxkkJC2h+X99oOIDzLUJNwvJJNxYD/o47h1ms9
xxMLL10s4mWFjFLy/MBs1VwzsiZvg1pT9SG187OJehEkJMg1/61etJvZwUmMKg9u
W0OmIRUT2TdZ0p/GaMZ+KSQz6NsjM+JXVMJmMAgkN9Z1Q/fwokT7N7ZJLflqkQ5P
FdDHTFXbDK1L/SiwcClSrgfMqMnGaFmNbzeVkdwG8ANIO8AFa8t2XKnnDK+0Iaae
bN3E4qLKFvNn+DcZtIdMNkpNhLQeiSp/8LY/ffI6bVcfnGZZyis0V+47KCwk1kDn
x7M5V61lQlqo0oGnR6cMPo0YDx2Usxr7Fq1AZAQCww31lkTevAdH/GqWDK+tYgTQ
DjJVnsVpEXUjMFRYFeBD
=/5Fb
-----END PGP SIGNATURE-----
--
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.