Qt TcpServer



  • Hi All,

    I have used Qt to write a TcpServer and Python as Client.
    The connection is OK. But the transfer of string is something else. Server cant readout the String from client.
    After research, it seems that it is difficult to use a client not wrote by Qt for communication. Is this true?
    Does anyone have a good idea ?

    thanks for reply!


  • Moderators

    @itsseven

    It depends how you transfer the information. The problem with a string is its definition. Especially where the end of the string is. You cannot send a string and the other side knows exactly what to with it. With most othe data types that is different. When you send a 4 byte integer and expect one on the other side. It is easy, but also mixing of types may be a problem. When you send a double but the other side expects an integer. Therefore in most cases you have to define your interface.

    For your specific case, it may be good enough to send the number of characters to like to send first followed by the actual string. Your client will receive the number of characters and can take the required steps to allocate the memory for the string. This is the way to send string which you want toreceive as a recognized string on the other side. It basically depends on what you like to do with it. E.g. for simple display functionality it may be even good enough to send the information byte by byte and place the received byte directly on screen.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.