Results 1 to 15 of 15

Thread: Packet getting fragmented when sending over QTcpSocket

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Location
    Poland, Łódź/Bełchatów
    Posts
    16
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Packet getting fragmented when sending over QTcpSocket

    Ehhhh, I thought there was some other way to do it
    Anyway, thank you for answer!
    Czesc
    Last edited by Kill3rReaper; 25th July 2009 at 22:24.

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

    Default Re: Packet getting fragmented when sending over QTcpSocket

    Quote Originally Posted by Kill3rReaper View Post
    Ehhhh, I thought there was some other way to do it
    Sure there is. Use QXmlStreamReader.
    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. #3
    Join Date
    Jul 2009
    Location
    Poland, Łódź/Bełchatów
    Posts
    16
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Packet getting fragmented when sending over QTcpSocket

    Ehhh... I just was writing new class for XML packets, when I try to write something XML to <body> </body> section... Code between these tags is interpretting by my algorism... When I was using QDomElement, I did't have got that problem What I can do?

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Packet getting fragmented when sending over QTcpSocket

    and what is the problem exactly?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Jul 2009
    Location
    Poland, Łódź/Bełchatów
    Posts
    16
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Packet getting fragmented when sending over QTcpSocket

    My english sux very much...
    For example:
    Qt Code:
    1. <message from='test@jab.com/Jabber' type='chat' xml:lang='pl' to='test@jabbim.pl'><active xmlns='http://jabber.org/protocol/chatstates'/><body>Hey!</body></message>
    To copy to clipboard, switch view to plain text mode 
    If I change body section to: "Hej <someth" my application freezes.

  6. #6
    Join Date
    Feb 2009
    Location
    Lexington, KY
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Packet getting fragmented when sending over QTcpSocket

    Quote Originally Posted by Kill3rReaper View Post
    My english sux very much...
    If I change body section to: "Hej <someth" my application freezes.
    I have not used the XML parser in Qt before, but other XML parsers would interpret the '<' symbol in the body as the opening to a tag. The parser would then read until it finds a closing '<' tag. Try converting the '<' to "&lt;" and see if your program still hangs.

    You can do the string conversion manually or for '<' and '>' with QString's replace string functions. There might be a method in one of the XML classes to quote characters that are meaningful to XML for you.

  7. #7
    Join Date
    Mar 2009
    Location
    Belchatow, Poland
    Posts
    38
    Thanks
    11
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default Re: Packet getting fragmented when sending over QTcpSocket

    Well, he can't change the packet cause that's the way the server sends it.

    My solution would be if you see the opening "body" tag, treat everything that follows as text untill you reach closing "body" tag. But that's not perfect cause someone could be chatting about HTML and send </body> and that would screw the parser up.

  8. #8
    Join Date
    Jul 2009
    Location
    Poland, Łódź/Bełchatów
    Posts
    16
    Thanks
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Packet getting fragmented when sending over QTcpSocket

    Quote Originally Posted by wrdieter View Post
    I have not used the XML parser in Qt before, but other XML parsers would interpret the '<' symbol in the body as the opening to a tag. The parser would then read until it finds a closing '<' tag. Try converting the '<' to "&lt;" and see if your program still hangs.

    You can do the string conversion manually or for '<' and '>' with QString's replace string functions. There might be a method in one of the XML classes to quote characters that are meaningful to XML for you.
    It's good idea
    I thought about use QDomElement class to solve this problem, but your solution sounds good
    P.S: I know that the XML parser interprets '<' symbol as the opening tag, but I could not cope with this ;/
    Last edited by Kill3rReaper; 5th August 2009 at 23:59.

Similar Threads

  1. QUdpSocket error
    By mdecandia in forum Qt Programming
    Replies: 8
    Last Post: 25th October 2007, 10:47
  2. qt network performance
    By criss in forum Qt Programming
    Replies: 16
    Last Post: 24th July 2006, 09:23

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.