[libnice] [Nice] Help sending data in reliable mode
philip at tecnocode.co.uk
Fri Apr 24 03:37:29 PDT 2015
A few things I've spotted:
• What's your reason for using threads? You need a good justification
for using them instead of a single GMainContext, or you will spend
months debugging race conditions.
• The call to g_pollable_output_stream_write_nonblocking() passes
buf_len, rather than len_file_read, which is incorrect and may be
causing your problems
• You are accessing sent_byte and read_byte across multiple threads
without locking; this won't cause problems at the moment, but is one
example of why threading is a really bad idea
If you are still having problems, I suggest simplifying the code further
to send fixed sample data (e.g. the byte sequence 0x00, 0x01, 0x02, …,
0xff, 0x00, …), and examining what goes over the network (using
Wireshark) and what you receive, to see if it matches what you sent. I
suspect any further problems will also be buffer management problems.
On Tue, 2015-04-14 at 12:33 +0200, fantasia.marco at gmail.com wrote:
> Hi Philip,
> I've extended my tests on these day, read all the test files in /test dir and I
> think I come in a solution for sending file through sockets in reliable mode. I
> based my code on test-send-recv.c file.
> Here it is what my code does:
> It gets ICE candidates in SDP-way, showing the encoded64 sdp like the sdp-
> example in /example dir.
> If the node is the controlling one, a write thread is created and then after
> established a reliable connection guaranted by stream_ready mutex, the
> encoded-64 file is sent on the stream socket.
> If the node is the controlled one, a read thread is created and after
> established a reliable connection is waiting for receinving the file with
> expected dimension.
> I tested the code in a local envoirement and in a real case scenario and I
> think I got think ordered.
> Tested my code on OpenSuse and Ubuntu.
> To compile the code you can exec these commands:
> gcc -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -
> I/usr/local/include/nice -I/usr/local/include -O0 -g3 -Wall -c -fmessage-
> length=0 -pthread -MMD -MP -MF"TestPseudoTcpFileTransfer.d" -
> MT"TestPseudoTcpFileTransfer.d" -o "TestPseudoTcpFileTransfer.o"
> and then link with
> gcc -L/usr/local/lib64 -o "TestPseudoTcpFileTransfer"
> TestPseudoTcpFileTransfer.o -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lnice
> I hope this will be helpful,
> In data martedì 14 aprile 2015 10:41:46, hai scritto:
> > Hi,
> > On Thu, 2015-03-12 at 17:12 +0100, Marco Fantasia wrote:
> > > I'm currenting writing a project in which two nodes communicate each
> > > other and the controlling agent sends data to the other one.
> > > I've implementing my communication structure using XMPP and I'm able
> > > to let my nodes communicate.
> > > You can find my project on GitHub:
> > > https://github.com/marcoxsurf/NiceStrophe/
> > > Now I have to let the controlling node to share a file to the
> > > controlled one. I have followed this discussion
> > > http://lists.freedesktop.org/archives/nice/2012-September/000633.html
> > > but I have still problems.
> > > Here it is the code that I'm testing:
> > Sorry, to be blunt, this is far too complex to expect people on a
> > mailing list to try and compile, test and debug for you.
> > If you can provide a minimal test case which reproduces your problem,
> > along with clear instructions for compiling it and reproducing the
> > problem, then people might be able to spend time investigating your
> > problem and helping you.
> > Sorry,
> > Philip
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 213 bytes
Desc: This is a digitally signed message part
More information about the nice