Persistent Qt Local Socket IPC -


I am developing an application that uses IPC between local server and client application. There is nothing special in it because it is structured like Qt documentation and examples.

The problem is that the client often sends packets and connects to the server / disconnecting the local socket (named pipes on NT) is very slow. So what I am trying to achieve is a "continuous" connection between the two apps.

(Connect ()), this, signal (connect ()); _blockSize = 0; _socket-> Abortion (); _socket-> Connect ToServer (name, QIODevice :: ReadWrite); }

and also sends the request in the traditional QT manner:

  zero IRtsClientImpl :: SendRequest (quint8 cmd, const QVariant * const param_array, unsigned int cParam ) {// Socket Data Send via QByteArray HDR (PROTO_BLK_HEADER_PROJ); Cubic Array Data Block; QDataStream Out (& Datablocks, QIODevice :: WriteOnly); Out.setVersion (QDataStream :: Qt_4_5); Quinn 8 command = cmd; Outside & lt; & Lt; Blocked_T (0) // Block size & lt; & Lt; HDR // Header & lt; & Lt; Quint32 (PROTO_VERSION_PROJ) // Protocol Version & lt; & Lt; Command // command & lt; & Lt; Carams; // The number of valid parameters (unsigned int i = 0; i & lt; caparam; ++ i) outside & lt; & Lt; Param_array [i]; // Write the current block size. Device () - & gt; Explore (0); Outside & lt; & Lt; DataBlock.size () - size (blockize_t); _socket-> About (dataBlock); }  

There is no problem. But this move remains on the readyRead () signal in the server-side. Here is the current implementation of the readyRead () handling slot:

  zero ItsServerImpl :: onReadyRead () {QDataStream in (_lsock); In.setVersion (QDataStream :: Qt_4_5); If (_blocksize == 0) {qDebug ("byte available on socket:% d", _lsock-> bytes available ()); If (_lsock-> Bytes Available () & lt; sizeof (blocksize_t)) Return; In & gt; & Gt; _block size; } // Do we need more data? If (_lsock-> Bytes Available () & lt; _blocksize) Return; (In) ReadRequest; // reset _blokis = 0; }  

I could not get more data without setting _blocksize for zero, only the first block group (I hope that a whole block without division Come to come because it is through a pipe, but this figure is not). I hope behavior, of course, because _blocksize does not represent the current stream flow. OK, reboot _blocks does the trick, but I can not send the second packet again from the client without the increasing array of bytes on the socket. What I need is to process the request in ReadRequest and get the next data block without connecting / reconnecting the included application.

Maybe I should 'regulate' the rate of incoming data?

Thank you very much.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -