Hi Christian,<br><br>I think I understand what you are saying but the data read comes directly from libpri and I cannot realize how can I put some data before the package, because I saw that into libpri there are two writes to my socket file descriptor but in the read part (inside my program thread) there are only one read with both packets togheter.
<br><br>After I receive the packet from libpri, I can send it directly to my card and the packet arrives at other side perfectly since my hardware already prepared to do it. The only problem is when I get two packets joint togheter.
<br><br>I´m thinking if using another kind of interprocess communication I can avoid this socketpair behaviour.<br><br>Thanks in advance!<br><br><br>Paulo<br><br><br><br><br><div><span class="gmail_quote">On 2/7/07, <b class="gmail_sendername">
Christian</b> <<a href="mailto:crich-ml@beronet.com">crich-ml@beronet.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Paulo,<br><br>i have had similar issues with a quite different use-case ;-) the<br>problem is that you need to frame your messages and transmit these<br>frames instead of the transparent data. you can use hdlc for example, i
<br>believe there are some simple implementations out there, but that is<br>sort of overkill. The most simple thing would be to just put the length<br>of the frame before each packet, the length could be of maximum 4 bytes,
<br>then do a read of just as much bytes which you know from this length, like:<br><br>uint32 len;<br>char buf[1024];<br>read(fd, &len, 4);<br>read(fd,buf,len);<br><br>then you can be sure that you've got only this single frame in buf,
<br>(well if read returns less then len you need to reread of course).<br><br>Besides that i have somewhere read that you can set a HDLC Property via<br>fcntl to terminals, but i haven't had ever the time to test that out.
<br><br><br>cheers,<br><br>christian<br><br><br>Paulo Garcia wrote:<br>> Hi,<br>><br>> in my own channel, I'm implementing ISDN support using Libpri. The<br>> implementation is completely independent from zaptel then I'm trying
<br>> to do all communications between my hardware and libpri using<br>> socketpair function.<br>><br>> The idea is to create a socketpair, passing fd[0] to pri_new function<br>> and writing to fd[1] to pass data to libpri. So far so good...
<br>><br>> To receive data from libpri, I have a thread checking for all file<br>> descriptors fd[1] using select() function and when I receive<br>> something, I pass it to my card. This approach also works well but
<br>> sometimes I receive two messages (from libpri) in only one read()<br>> call. I think this is because of libpri writes two messages so fast<br>> then when the read is called, there are already two messages in socket
<br>> buffer...<br>><br>> How can I avoid this behavior? Maybe using another way different of<br>> socketpair ? This communication will be used only inside the same<br>> process, between different threads.<br>
><br>> Any path or idea will be appreciated.<br>><br>><br>> Regards<br>><br>><br>> Paulo Garcia<br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________
<br>> --Bandwidth and Colocation provided by <a href="http://Easynews.com">Easynews.com</a> --<br>><br>> asterisk-dev mailing list<br>> To UNSUBSCRIBE or update options visit:<br>> <a href="http://lists.digium.com/mailman/listinfo/asterisk-dev">
http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br>><br><br>_______________________________________________<br>--Bandwidth and Colocation provided by <a href="http://Easynews.com">Easynews.com</a> --<br><br>asterisk-dev mailing list
<br>To UNSUBSCRIBE or update options visit:<br> <a href="http://lists.digium.com/mailman/listinfo/asterisk-dev">http://lists.digium.com/mailman/listinfo/asterisk-dev</a><br></blockquote></div><br>