3 * (c) Copyright 2007 by Intra2net AG
8 #include "async_pipe.hpp"
11 #include <boost/bind.hpp>
14 #include <sys/types.h>
15 #include <sys/socket.h>
24 * Implementation of SimplePipe
27 SimplePipe::SimplePipe()
29 m_signal_read.connect(boost::bind(&SimplePipe::slotReceived,this));
30 } // eo SimplePipe::SimplePipe()
33 SimplePipe::~SimplePipe()
35 } // eo SimplePipe::~SimplePipe()
40 * This method connects itself with a newly created peer object with a bidirectional pipe.
41 * @return the peer pipe object.
43 bool SimplePipe::makePipe(SimplePipe& peer)
45 close(); // just in case...
49 int res= ::socketpair( AF_UNIX, SOCK_STREAM, 0, fds);
61 peer.close(); // just in case
66 peer.setWriteFd(fds[1]);
67 peer.setReadFd(fds[1]);
70 } // eo SimplePipe.:makePipe()
74 * sends a string through the pipe.
75 * @param data the data which should be sent to the other side.
77 void SimplePipe::sendString(const std::string& data)
80 } // eo SimplePipe::sendString(const std::string&)
84 * emits the signal signalReceived with the received data.
85 * This slot is connected to IOImplementation::m_signal_read.
87 void SimplePipe::slotReceived()
90 data.swap(m_input_buffer);
91 signal_received_string(data);
92 } // eo SimplePipe::slotReceived()
95 } // eo namespace AsyncIo