Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I can not receive simple int values over a socket
Forum Updated to NodeBB v4.3 + New Features

I can not receive simple int values over a socket

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 490 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    quter
    wrote on last edited by tekojo
    #1

    Hi,
    I use a tcp socket with a signal slot mechanism to send and receive messages from a java socket server.
    My problem is the function readReady will just called if I send a string. But I want to send and receive an int.
    Is there an way to do it? Or can i just receive strings?

    My code:

    connect(socket,SIGNAL(readyRead()),this,SLOT(readReady()));
    
    void TcpSocketCon::readReady()
    {
        qDebug()<<"Read from Socket";
        qDebug()<<socket->readAll();
    }
    
    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      In which way is your int send?
      If it is sent binary, you will have to extract it from your buffer. There is no automatic conversion. With QByteArray you may use toInt() However, you need to know the information type to be received.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved