Kevin P. Fleming wrote:
Vadim Lebedev wrote:
You're right but only in the case that when you have separtae briding
threads for each direction.
I was thinkin about situation when there is ONE briging theard for two
directions. The you can you the same pipe
for both direction.
No, you cannot. How are you going to distinguish packets that belong to
the A->B direction from the ones that belong to the B->A direction if
both of them are being written to the 'write' end of the same pipe?
Instead of just proposing this idea without fully understanding how it
would work (here on the developer mailing list), it would be much better
if you wrote a small program demonstrating the technique and proving
that it is possible. Otherwise this is all just speculation and people
disagreeing about what may or may not work.
Certainly it is not at all possible to create a single pipe and using it
for both directions of multiple bridges... I don't know how you came to
the conclusion that could work at all.
Ok, i'll write a demo program this week....
But the basic approach is trivial:
FD_SET(&readset, source_fd);
FD_SET(&readset, target_fd);
N = 1 + max(source_fd, target_fd);
select(N, &readset, 0, 0, &timeout);
if (FD_ISSET(&readset, source_fd))
{
// copy from source to target
slice(source_fd, mypipe[0], .....);
slice(mypipe[1], target_fd);
}
else if (FD_ISSET(&readset, target_fd))
{
// copy from target to source
slice(target_fd, mypipe[0], .....);
slice(mypipe[1], source_fd);
}
The trick is that the pipe is ALWAYS empty.... And when we push
something to the pipe, we pull the data from it immideately afterwards.
Thanks
Vadim
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev
_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev