[libnice] How to properly use the function nice_agent_get_io_stream()

Olivier Crête olivier.crete at collabora.com
Tue May 13 11:31:31 PDT 2014

On Sun, 2014-05-11 at 23:31 +0200, silvio wrote:
> 1) g_input_stream_read()
> When using unix read() or recv(), they usually block until some input is
> available. Then that input is written to the buffer and the function
> returns.
> g_input_stream_read() here seems to wait until the entire buffer can be
> filled. I don't know glib at all but I would think that is what
> g_input_stream_read_all() is for.

Good question, my impression was that this is how g_input_stream_read()
worked on regular TCP sockets. We should test, the goal is to match the
same behavior.

> I tricked libnice into that behavior by using combining.
> nice_agent_recv(... 1 ...);
> nice_agent_recv_nonblocking(... buffer_size-1 ...);
> However, this would be better solved in the library.

You can use g_pollable_input_stream_create_source() to have a source
that will trigger when there may be something to read.

> 2) onesided shutdown of pseudo tcp:
> If i do close the GOutputStream of GIOStream nothing seams to happen.
> Ideally the TCP connection would be half closed. And any reading
> function on the other side would return eof.
> This is required for even simple things like netcat. Imagine how netcat
> terminates if you connect like this to a simple echo server.
> echo foo | nc echoserver.example.org echoport

Yeah. It's a known problem with the PseudoTCP code, it doesn't have a
FIN at all. The touchy thing is that we want to keep our PseudoTCP code
compatible with Google's, and they don't have that either.

> 3) timeout
> when i kill one of the participants i see that some packets are still
> sent from the other periodically but the other participant never fires
> component-state-changed signal. I would except it to go into some fail
> state after some timeout.

ICE doesn't have a timeout mechanism, you have to provide it at the
higher layer. That said, a compliant ICE agent should reply to binding
requests, and we already have code to do connectivity checks in the
Google compatible mode, so we could hook that up in the standard mode
too somehow.

Olivier Crête
olivier.crete at collabora.com

More information about the nice mailing list