Results 1 to 6 of 6

Thread: QUdpSocket and ShareAddress

  1. #1
    Join Date
    Mar 2007
    Posts
    29
    Thanks
    2

    Default QUdpSocket and ShareAddress

    Hi all,
    I'm using QUdpSocket in a client-server environment and I want to improve performance sharing listen port between more identical server processes.
    All datagrams are processed by all processes but I want to split them between processes.
    I used the bind mode SharedAddress to bind sockets to same port but nothing changed.
    Server socket binding and datagram processing is done as follows:

    ------ Binding
    udpSocket = new QUdpSocket();
    udpSocket->bind(portNum,QUdpSocket::ShareAddress);
    connect(udpSocket, SIGNAL(readyRead()),
    this, SLOT(processPendingDatagrams()));

    ---- Datagram Processing Slot

    void Receiver:rocessPendingDatagrams()
    {
    while (udpSocket->hasPendingDatagrams()){
    QByteArray datagram;
    datagram.resize(udpSocket->pendingDatagramSize());
    udpSocket->readDatagram(datagram.data(), datagram.size());

    }

    }

    Do you have experience with this?

    Thanks,
    Michele

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QUdpSocket and ShareAddress

    are the servers all on the same machine?

  3. #3
    Join Date
    Mar 2007
    Posts
    29
    Thanks
    2

    Default Re: QUdpSocket and ShareAddress

    Yes, they are.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QUdpSocket and ShareAddress

    so how do you want all of them to use the same port?

  5. #5
    Join Date
    Mar 2007
    Posts
    29
    Thanks
    2

    Default Re: QUdpSocket and ShareAddress

    From Qt docs I've read this:

    QUdpSocket::ShareAddress : Allow other services to bind to the same address and port. This is useful when multiple processes share the load of a single service by listening to the same address and port (e.g., a web server with several pre-forked listeners can greatly improve response time). However, because any service is allowed to rebind, this option is subject to certain security considerations. Note that by combining this option with ReuseAddressHint, you will also allow your service to rebind an existing shared address. On Unix, this is equivalent to the SO_REUSEADDR socket option. On Windows, this option is ignored.

    I think this means that more services may share a unique port.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QUdpSocket and ShareAddress

    Well, I learned somethig today.
    I can't help you though...

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.