Results 1 to 3 of 3

Thread: Fortune Server example

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: Fortune Server example

    Don't double post, please.

    It's well explained in the example:
    Qt Code:
    1. out << (quint16)0;
    2. out << fortunes.at(qrand() % fortunes.size());
    3. out.device()->seek(0);
    4. out << (quint16)(block.size() - sizeof(quint16));
    To copy to clipboard, switch view to plain text mode 
    At the start of our QByteArray, we reserve space for a 16 bit integer that will contain the total size of the data block we are sending. We continue by streaming in a random fortune. Then we seek back to the beginning of the QByteArray, and overwrite the reserved 16 bit integer value with the total size of the array. By doing this, we provide a way for clients to verify how much data they can expect before reading the whole packet.
    In other words, it's the size of the fortune, which is the size of the whole block minus the size of the quint16 in the beginning.
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    babu198649 (21st December 2007)

  3. #2
    Join Date
    Feb 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Fortune Server example

    hello,
    when i run the fortune server , it says me to run the fortune client and when i run fortune client alongside, and i enter the port no and click get fortune button, it doenot proceed any further and continues to say now run fortune server example alongside

Similar Threads

  1. How to download any file through ftp server
    By thomasjoy in forum Qt Programming
    Replies: 1
    Last Post: 24th July 2007, 01:23
  2. How to ping a server ?
    By Nyphel in forum Newbie
    Replies: 2
    Last Post: 23rd April 2007, 11:27
  3. cannot connect to X server
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2007, 14:22
  4. How a server can write "Hello" to a browser ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 1st December 2006, 14:43
  5. synching client readings to server output
    By OnionRingOfDoom in forum Qt Programming
    Replies: 14
    Last Post: 28th January 2006, 18:15

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.