Results 1 to 6 of 6

Thread: How to use matching settings for synchronous and asynchronous pipes

  1. #1
    Join Date
    Oct 2016
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default How to use matching settings for synchronous and asynchronous pipes

    Hello everyone,

    I have written client application with Qt using QLocalSocket class. As I know Qt opens asynchronous I/O pipes. What if a server was not written in Qt (so it opened synchronous I/O pipe)? Is it possible to tell my client to connect to synchronous I/O pipe? How to use matching settings in such situations? I can change only client side - I do not have access to the server code which is syslog_ng application. When client tries to connect I obtain error: ConnectionRefusedError.
    Last edited by cyki; 25th October 2016 at 18:06.

  2. #2
    Join Date
    Oct 2016
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use matching settings for synchronous and asynchronous pipes

    I am using Linux OS. I have written server application with Qt using QLocalServer class and my client communicates with this server correctly. The problem occures when pipe is open by application that was not written in Qt, e.g. I create named pipe by means of linux command:
    $ mkfifo /tmp/test
    Then I write some text into this pipe:
    $ echo "this is my text" > /tmep/test &
    Now I can read this pipe by means of cat application:
    $ cat /tmp/test
    but when I am trying to read this pipe by means of my client I receive following error: ConnectionRefusedError.
    Is it some kind of incompability? Does asynchronous and synchronous I/O pipe concern only Windows or Linux as well?

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use matching settings for synchronous and asynchronous pipes

    Quote Originally Posted by cyki View Post
    I have written client application with Qt using QLocalSocket class. As I know Qt opens asynchronous I/O pipes. What if a server was not written in Qt (so it opened synchronous I/O pipe)?
    Not a problem, server and clients are independent.

    Quote Originally Posted by cyki View Post
    Is it possible to tell my client to connect to synchronous I/O pipe?
    A socket is neither sychronous nor asynchronous, it simply is.
    Any participant can open it they way it wants to, without any impact on its peer.

    Quote Originally Posted by cyki View Post
    I create named pipe by means of linux command:
    $ mkfifo /tmp/test
    Probaly a misunderstanding, but this is a pipe, not a Unix domain socket.

    Cheers,
    _

  4. #4
    Join Date
    Oct 2016
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use matching settings for synchronous and asynchronous pipes

    Ok, thanks for the answer!

    How to create then an application in Qt that will read pipe created by means of mkfifo command?
    I used QLocalSocket class in following way:

    localSocket = new QLocalSocket(this)
    localSocket->connectToServer(/tmep/test, QIODevice::ReadOnly)

    but connectToServer() function returns ConnectionRefusedError.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use matching settings for synchronous and asynchronous pipes

    QLocalSocket uses Unix Domain sockets, not pipes.

    You can use system I/O API but very likely also QFile.

    Cheers,
    _

  6. The following user says thank you to anda_skoa for this useful post:

    cyki (26th October 2016)

  7. #6
    Join Date
    Oct 2016
    Posts
    4
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to use matching settings for synchronous and asynchronous pipes

    OK, now it's clear. Thanks for the help

Similar Threads

  1. Replies: 2
    Last Post: 16th September 2014, 17:56
  2. Named pipes in Qt
    By xenko in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2012, 10:05
  3. QProcess pipes problem
    By benacler in forum Qt Programming
    Replies: 6
    Last Post: 7th December 2007, 19:30
  4. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 10th April 2007, 00:11
  5. Asynchronous server msg vs synchronous functions
    By nouknouk in forum Qt Programming
    Replies: 9
    Last Post: 2nd February 2006, 18:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.