Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:49:39+00:00 2026-06-07T03:49:39+00:00

I’m using C++ with QT4 for this. And when I try to send large

  • 0

I’m using C++ with QT4 for this. And when I try to send large html files(in this case, 8kb), the process of sending and receiving work well. But the file received come with spaces between each character of the html file. Here an example, the file is sent like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">a</p></body></html>

and it’s received, like this:

  ¼ < ! D O C T Y P E   H T M L   P U B L I C   " - / / W 3 C / / D T D   H T M L   4 . 0 / / E N "   " h t t p : / / w w w . w 3 . o r g / T R / R E C - h t m l 4 0 / s t r i c t . d t d " > 
 < h t m l > < h e a d > < m e t a   n a m e = " q r i c h t e x t "   c o n t e n t = " 1 "   / > < s t y l e   t y p e = " t e x t / c s s " > 
 p ,   l i   {   w h i t e - s p a c e :   p r e - w r a p ;   } 
 < / s t y l e > < / h e a d > < b o d y   s t y l e = "   f o n t - f a m i l y : ' M S   S h e l l   D l g   2 ' ;   f o n t - s i z e : 8 . 2 5 p t ;   f o n t - w e i g h t : 4 0 0 ;   f o n t - s t y l e : n o r m a l ; " > 
 < p   s t y l e = " - q t - p a r a g r a p h - t y p e : e m p t y ;   m a r g i n - t o p : 0 p x ;   m a r g i n - b o t t o m : 0 p x ;   m a r g i n - l e f t : 0 p x ;   m a r g i n - r i g h t : 0 p x ;   - q t - b l o c k - i n d e n t : 0 ;   t e x t - i n d e n t : 0 p x ; " > < / p > < / b o d y > < / h t m l >

the code i’m using for sending and receiving:

Sending code:

qDebug() << "Connected. Sending file to the server"; QString text = ui->QuestHtmlText->toPlainText();

if(text.length() < 1024)
{
    QByteArray block;
    QDataStream out(&block, QIODevice::WriteOnly);
    out << quint16(0) << QUESTION_HTML;
    out << text;
    out.device()->seek(0);
    out << quint16(block.size() - sizeof(quint16));
    qDebug() << "Block size: " << block.size();
    socket.write(block);
    return;
}

for(int i = 0; i < text.length(); i+=1024)
{
    QByteArray block;
    QDataStream out(&block, QIODevice::WriteOnly);
    out << quint16(0) << QUESTION_HTML;
    if((text.length() - i) > 1024)
        out << text.mid(i, i+1024);
    else
        out << text.right(1024 - i);
    out.device()->seek(0);
    out << quint16(block.size() - sizeof(quint16));
    qDebug() << "Block size: " << block.size();
    socket.write(block);
}

Receiving code:

qDebug() << "Writing File";
QDataStream in(this);
QString temp = "Teste.html", text;
QFile myFile(".//Questions//" + temp);
myFile.open(QIODevice::WriteOnly);
QDataStream out(&myFile);
while(!in.atEnd())
{
    in >> text;
    out << text;
}

I did opened a post before, here: Sending data through socket spaces, receiving with spaces

People stopped helping me out. By the way, i didnt feel like my question was completly answered. So I opened another post.
I also looked in the FAQ section to see what should I do in this case. But with no sucess.

Anyway, my question now is: should I remove the quint16? what should I use to determine the size of the incoming packet then ?

Thanks, and I’m sorry about the mistakes I may have made.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:49:40+00:00Added an answer on June 7, 2026 at 3:49 am

    I posted the solution for my case in the other post.

    Thanks you all for the attention

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.