From kde-devel Sat Sep 13 11:30:56 2003 From: Jeroen Wijnhout Date: Sat, 13 Sep 2003 11:30:56 +0000 To: kde-devel Subject: Re: reading from a pipe KIO::Connection? X-MARC-Message: https://marc.info/?l=kde-devel&m=106345314024155 On Saturday 13 September 2003 10:54, Jeroen Wijnhout wrote: > Hi, > > I'm trying to read from a name pipe (FIFO) using the class KIO::Connection, > however I'm not able to read from a pipe at all (the receive() slot is > never called). Can somebody help me to get this code right, or give another > way to read from a pipe? A slot should be activated if there is data to be > read from the pipe (or a mechanism like in kprocess would actually be > nicer). Hi again, I've changed the code to use QSocketNotifier. There are two problems. First of all, the mainwindow is not shown before some data is sent to the pipe. The second problem is that QSocketNotifier keeps firing the activated() signal, although I am ready all the data. Any ideas? thanks, Jeroen lyxserver::lyxserver() : KMainWindow( 0, "lyxserver" ) { // set the shell's ui resource file setXMLFile("lyxserverui.rc"); QHBoxLayout *layout = new QHBoxLayout(this); layout->addWidget(m_te = new KTextEdit(this, "ml_edit" )); show(); m_pipeIn = new QFile("/home/wijnhout/.lyxpipe.in"); if (m_pipeIn->open(IO_ReadOnly)) { kdDebug() << "pipeIn opened with handle " << m_pipeIn->handle() << endl; } else kdError() << "could not open pipeIn" << endl; m_notifier = new QSocketNotifier(m_pipeIn->handle(),QSocketNotifier::Read, 0); connect(m_notifier, SIGNAL(activated(int)), this, SLOT(receive())); } lyxserver::~lyxserver() { } void lyxserver::receive() { kdDebug() << "reading data..." << endl; m_notifier->setEnabled(false); QString line; while ( m_pipeIn->readLine(line, 80) > -1) { m_te->append(line); } kdDebug() << "done" << endl; m_notifier->setEnabled(true); } Kile - a LaTeX editor for KDE http://kile.sourceforge.net >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<