-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 04/27/2014 01:53 PM, Iñaki Baz Castillo wrote: > 2014-04-27 13:47 GMT+02:00 Iñaki Baz Castillo <[email protected]>: >> I'm building a RTP media server which means I need to bind in >> many random UDP ports: for each RTP session I need two sequential >> ports, the first for RTP (ex: 15054) and the second for RTCP (ex: >> 15055). >> >> This means that I will check for random ports (I don't want to >> keep a list of "used ports" because I use N threads with separate >> UV loops and don't want to access shared memory) so uv_udp_bind() >> may fail with EADDRINUSE. >> >> In that case, could I reuse the same uv_udp_t pointer with a new >> sockaddr? If so, do I need to call uv_udp_init again for the same >> handle? > > > Humm, in uv__udp_bind() I see: > > -------------------------------------- if (bind(fd, addr, addrlen)) > { err = -errno; goto out; } > > [...] return 0; > > out: uv__close(handle->io_watcher.fd); handle->io_watcher.fd = -1; > return err; ---------------------------------- > > So it seems that the socket gets invalidated after uv_udp_bind() > fails, and thus I cannot reuse the uv_udp_t handle again with > another address, am I right? >
Yes. Generally speaking, if any networking related handle fails you need to close it and create a new one. - -- Saúl Ibarra Corretgé bettercallsaghul.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBAgAGBQJTXQIVAAoJEEEOVVOum8BZqPMP/A80bZSkqS2/G9tBNu3+ppVr 14pqaFeJPFLipLhQ7N1faNffstxTm+QxJBUITFQxQQWWGO/uyx/Qci2TZBAy3LRZ BTLI9vb+FGeT5LTfvf3VfVdQ7x7SntTGF0ej1tsC9SAiCvBmTTLjmUOmqMdOqxMP 2/aHPKLUghsaqZb1Edx/TWs4ReGVAC7tqCXDyHZkjCxGmmQwCyo1GZCqArkiqc6J lrClGruYItZbahUnidd9PYcI8r5xG+xsFR37dt3uOPhXXd1VB9E0VyBchJsKhx5V ylbk3/u1iWILg5LtQKg5wNuds+2e1zbjDxYZCAvYtazW8CHnnYLYS0aGYrg6xokN QqPDb2nxh+o+Yyu8OPE30MZCHPZHrX1lohs0KpqmcICyY7M0zpIQM9CCdhHJWTva QVCoRhroqzRKGNsI2irejEPL9xJgtazhraqz00taulLv06xvrpKMIzJDJq6LxP8s adPnZ6lQOxdzYJqxCV4Q3PVs6WL9IC782Yp0Jt/oPBQ/4RPks/aP2JRDAdthpExR c7qi8PDWY5SJMFF83LrUaCkTRWeUt1HIo8B04JhOmME51X38u7pzB0L2h8OxoMyo +Ysg+IbYl43BfSA25NV5iEi9zodFOnoeYxgIFgLZn5TbM57KSoIXSksDwSYdPCXc JPQQTlPzKfZrr5/IHgKD =FbDN -----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.
