[Nice] Using libnice address candidates with normal C sockets

Youness Alaoui youness.alaoui at collabora.co.uk
Thu Jun 27 14:39:26 PDT 2013

Hi Daniel,

Sorry for the late response.

You can't use libnice to only do the discovery of your ports then use normal
sockets for it. ICE stands for "Interactive Connectivity Establishment", where
the important term here is "Interactive". The way libnice works is by not only
gathering the potential candidates for the peers but also by making sure the
connection is established correctly by sending connectivity checks that must be
authenticated (because a router might redirect the data on the port to a
different computer on the same network for example). Also, there is the use case
where you can't connect to the other peer because one of you is using a symetric
NAT. In that case, libnice has an algorithm to counter it by dynamically
creating new candidates during the connectivity establishment, which means that
doing the candidate discovery and just using the ports will not work in such a
case. If you want to implement something similar in your own code, then don't
forget that ICE is a specification of 117 pages (See
http://tools.ietf.org/html/rfc5245 ) and that all of that is pretty much needed
to ensure proper connectivity establishment.
If you have any questions on how to use libnice or how it works, feel free to ask.


On 04/15/2013 07:43 AM, Daniel Lobo wrote:
> Hi.
> I'm working with C sockets and currently have "peers" connecting to each other
> in the same machine, without using libnice at all. Now, I want to make this
> system work when peers are in different networks and behind NATs, taking
> advantage of P2P.
> My main question is: can I use libnice to find me the peer connection endpoints
> and then use those addresses with a normal socket (both listening at/connecting
> to that address)?
> I more or less did this, but only because the peers were all in the same machine
> and addresses were all from my network/machine. Is this possible when in
> different networks? (I'm sorry for asking but I can't test it with my current
> test environment...)
> The recent libnice examples (simple-example.c) certainly do not use normal C
> sockets, and I fear I cannot fully comprehend what is going on. I believe that
> the candidates might be "any" used address from one machine to the other, going
> through routers, but, if that is so, how can I bind a socket to one of the local
> addresses which are outside my network? Does it work? (again, I can't currently
> test it) What does libnice itself do to bind/connect when linking the two peers?
> Can we access the information it uses and do the same?
> I apologize for all the questions, but they are closely related, I think :)
> Thank you,
> Daniel.
> _______________________________________________
> nice mailing list
> nice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/nice

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 263 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/nice/attachments/20130627/fae08533/attachment.pgp>

More information about the nice mailing list