named pipes in boost for Linux

Hi, Could anyone please let me know if named pipes are implemented in boost for Linux for communication between two processes which are not child and parent. I could not find in the documentation that named pipes are implemented so far. Is there information that they will be implemented in future versions. Please let me know if my query is not clear. Regards, Rohini Chandra

Hi Bruno,
Thank you for the reply.
I have seen this documentation before. It says that two processes have to be
related.
Boost.Process enables processes to communicate with each other only if they
are related: One process must have created the other. If you want two
processes which are not related to exchange data you should use
Boost.Interprocess http://www.boost.org/libs/interprocess/.
After reading the above sentences, I did not further read Boost.Process. And
Boost.Interprocess does not offer pipes from what I understood. I had used
boost message queues for my work but due to a short coming in the boost
message queues, I am looking for another IPC technique to replace them. The
short coming I refer to in boost message queues is being not able to wait on
a message queue. I mean that it seems to be not possible to get a file
descriptor of a boost message queue.
Best Regards,
Rohini Chandra
On Fri, Dec 17, 2010 at 6:47 PM, bruno romano
Boost.Process
http://www.highscore.de/cpp/process/
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Sat, 18 Dec 2010 11:52:19 +0100, rohini chandra pallapothu
[...]I have seen this documentation before. It says that two processes have to be related.
Rohini,
you can download the latest draft of Boost.Process from
http://www.highscore.de/boost/gsoc2010/process.zip. This version provides
stream behaviors to configure streams of a child process. Among others a
stream behavior for named pipes is provided. You could use it like this:
named_pipe np("/tmp/mypipe");
stream_ends ends = np(input_stream);
... = ends.child.native();
... = ends.parent.native();
The parameter passed to named_pipe::operator()() tells the stream behavior
if the child handle should be configured for input or output. stream_ends
is basically a std:pair
[...]

Thank you Boris, but I need to setup IPC between two processes which are not
child and parent.
I had used boost message queues as of now for the same but I am not able to
wait on the boost message queue as it is not possible to get a file
descriptor of a boost message queue. To my understanding, native() method
cannot be used on a boost message queues.
Now, I want to use some other IPC technique other than boost message queues
due to the above reason. So I thought of checking if pipe communication is
possible between two unrelated processes using boost.
Could you please help me if you have more information regarding this.
Please let me know if you need more information to help me.
Best Regards,
Rohini Chandra
On Sat, Dec 18, 2010 at 5:05 PM, Boris Schaeling
On Sat, 18 Dec 2010 11:52:19 +0100, rohini chandra pallapothu < rohinichandrap@gmail.com> wrote:
[...]I have seen this documentation before. It says that two processes
have to be related.
Rohini,
you can download the latest draft of Boost.Process from http://www.highscore.de/boost/gsoc2010/process.zip. This version provides stream behaviors to configure streams of a child process. Among others a stream behavior for named pipes is provided. You could use it like this:
named_pipe np("/tmp/mypipe"); stream_ends ends = np(input_stream); ... = ends.child.native(); ... = ends.parent.native();
The parameter passed to named_pipe::operator()() tells the stream behavior if the child handle should be configured for input or output. stream_ends is basically a std:pair
without requiring developers to remember what the child and the parent handle is. And the method handle::native() (and handle::release()) can be used to get the file descriptor on Unix and the HANDLE on Windows. HTH, Boris
[...]
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Sun, 19 Dec 2010 00:12:50 +0100, rohini chandra pallapothu
[...]Now, I want to use some other IPC technique other than boost message queues due to the above reason. So I thought of checking if pipe communication is possible between two unrelated processes using boost.
Could you please help me if you have more information regarding this.
I think the fastest solution for you is to copy&paste the code from the stream behavior named_pipe in Boost.Process. One process needs to call mkfifo() and open() and the other process only open(). If you set the O_NONBLOCK flag with fcntl() you can even use asynchronous I/O with Boost.Asio (see boost::asio::posix::stream_descriptor). It's not a Boost solution but copying and adapting the code shouldn't take longer than a few minutes. :) Boris
[...]

Thank you Boris for the help. I was also thinking of using native Linux
IPC(message queues or pipes) if I cannot do it in boost.
Best Regards ,
Rohini Chandra
On Sun, Dec 19, 2010 at 1:04 AM, Boris Schaeling
On Sun, 19 Dec 2010 00:12:50 +0100, rohini chandra pallapothu < rohinichandrap@gmail.com> wrote:
[...]Now, I want to use some other IPC technique other than boost message
queues
due to the above reason. So I thought of checking if pipe communication is possible between two unrelated processes using boost.
Could you please help me if you have more information regarding this.
I think the fastest solution for you is to copy&paste the code from the stream behavior named_pipe in Boost.Process. One process needs to call mkfifo() and open() and the other process only open(). If you set the O_NONBLOCK flag with fcntl() you can even use asynchronous I/O with Boost.Asio (see boost::asio::posix::stream_descriptor). It's not a Boost solution but copying and adapting the code shouldn't take longer than a few minutes. :)
Boris
[...]
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi, you see this page ? http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/examples.html (several examples using boost.asio) http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/local/conne... (named_socket for linux) http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/local/strea... for linux) http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/local/strea... for linux) Boost.Asio have asynchronous methods to read and write, and have a method native.

Thank you Bruno. I have not seen these examples. I'll go through them and
see if I can use them in my application
Thank you once again.
Best Regards,
Rohini ChandratPM, bruno romano
Hi, you see this page ?
http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/examples.html (several examples using boost.asio)
http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/local/conne... (named_socket for linux)
http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/local/strea... for linux)
http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/local/strea... for linux)
Boost.Asio have asynchronous methods to read and write, and have a method native.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
Boris Schaeling
-
bruno romano
-
rohini chandra pallapothu