Results 1 to 2 of 2

Thread: Server sending gibberish to the client.

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Server sending gibberish to the client.

    I'm coding this client/server application for chatting. My client is able to send messages to the server, so is the server to the client but, messages from server to client can only be sent in this form
    Qt Code:
    1. socket->write("Hello Client! Meassage from Server!");
    To copy to clipboard, switch view to plain text mode 
    but when i do this
    Qt Code:
    1. QByteArray clientMsg;
    2. clientMsg.append(("Hello Client! Meassage from Server!")
    To copy to clipboard, switch view to plain text mode 
    the client displays some ascii gabbage. what is coursing this? am i doing something wrong? The reason for me wanting to use the second method is that I want to take a message from one client application and relay it to another client via the server. But the way I am using the
    Qt Code:
    1. readAll()
    To copy to clipboard, switch view to plain text mode 
    function to read data from the socket on the client side. Any help will be appreciated.

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

    Default Re: Server sending gibberish to the client.

    What do you do with "clientMsg" after the lines of code that you posted? How do you feed it to the socket? How are you reading data on the other end? Are you expecting the whole message to come in one piece or do you have any marks that let you determine that you have received the whole message?
    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. client sending data line by line to server in Qt
    By ajay in forum Qt Programming
    Replies: 3
    Last Post: 31st August 2012, 00:06
  2. QTcpSocket get disconnected when server is sending huge data
    By KernelCoder in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2011, 08:45
  3. [TCP Server] Server only sending when terminating
    By papperlapapp in forum Qt Programming
    Replies: 0
    Last Post: 6th December 2010, 19:41
  4. Sending string from QT client to Java server
    By seanmu13 in forum Qt Programming
    Replies: 10
    Last Post: 3rd July 2007, 12:52
  5. Sending string from QT client to Java server
    By seanmu13 in forum Newbie
    Replies: 3
    Last Post: 3rd July 2007, 12:20

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.