Results 1 to 16 of 16

Thread: Server programming - Best Practices

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: Server programming - Best Practices

    Yeah I noticed that during testing and now I'm a little stomped. I guess there is no asynchronous implementation of that function ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Server programming - Best Practices

    Sure there is. It's the readyRead() signal
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Affenbrotbaum (19th January 2011)

  4. #3
    Join Date
    Jan 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    2

    Default Re: Server programming - Best Practices

    Hehe ok now I'm confused . The above code in post #6 is what's connected to the readyRead() signal. Only 2 differences are a) The QDataStream now gets created once per socket when I'm working through the TcpServer::hasPendingConnections() list and b) I limit the data being received since I know all the strings and their length that are permitted to be submitted (socket->bytesAvailable()). I just had for testing purposes a waitForReadyRead() in there to see how it behaves with large or no data coming in.

    So far, everything seems to be working now. I'll post some code this weekend so other people have an example of this whole conversation. Thank you very much for all the help

    Cheers
    Alex

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Server programming - Best Practices

    Quote Originally Posted by Affenbrotbaum View Post
    The above code in post #6 is what's connected to the readyRead() signal.
    That's correct and that's the right approach. But the code you put inside the slot connected to this signal is relevant.

    b) I limit the data being received since I know all the strings and their length that are permitted to be submitted (socket->bytesAvailable()).
    And that's your problem. You assume the data is going to look like you expect it. A good server is not one that behaves correctly for the data it expects, that's easy to achieve. A good server behaves correctly for the data (and behaviour) it doesn't expect.


    I just had for testing purposes a waitForReadyRead() in there to see how it behaves with large or no data coming in.

    So far, everything seems to be working now.
    Such tests are useless.

    With the code you posted so far I can compromise your whole server computer (not only your application) within seconds.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. programming practices with connect
    By jajdoo in forum Qt Programming
    Replies: 6
    Last Post: 5th September 2010, 14:19
  2. server-side app CGI Programming.
    By jcr in forum Newbie
    Replies: 0
    Last Post: 15th January 2009, 11:37
  3. query about best practices
    By Raajesh in forum Qt Programming
    Replies: 3
    Last Post: 13th June 2008, 19:47
  4. Programming client-server with socket in multi-languages
    By philiptine in forum Qt Programming
    Replies: 3
    Last Post: 7th September 2007, 08:35
  5. Qt <-> Java - Best Practices?
    By mentat in forum Qt Programming
    Replies: 6
    Last Post: 20th July 2006, 03:32

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
  •  
Qt is a trademark of The Qt Company.