title: Qt Reading data from socket
body: <p>I'm trying to implement a TCP/IP client using Qt 5.7. Currently I have these line in my code </p>
  
  <pre><code>_socket = new QTcpSocket();
  _socket-&gt;connectToHost(hostIp,_port);
  if(_socket-&gt;waitForConnected(2000)){
          qDebug() &lt;&lt; "Connected!";
          qDebug() &lt;&lt; _socket-&gt;peerAddress();
  }
  connect( _socket, SIGNAL(readyRead()),this, SLOT(readTcpData()) );
  
  
  }
  
  void eegClient::readTcpData()
  {
      QByteArray data = _socket-&gt;readAll();
  }
  </code></pre>
  
  <p>I tried testing this code with a simply python server:</p>
  
  <pre><code>import socket
  import sys
  
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  server_address = ('localhost', 10003)
  sock.bind(server_address)
  
  
  sock.listen(1)
  
  while True:
      print &gt;&gt; sys.stderr, 'waiting for a connection'
      (connection, client_address) = sock.accept()
      try:
          print &gt;&gt; sys.stderr, 'connection from', client_address
          while True:
              if 1:
                  BUFFER = "a string"
                  connection.sendall(BUFFER)
              else:
                  print &gt;&gt; sys.stderr, 'no more data from', client_address
                  break
      finally:
  
          # Clean up the connection
  
          connection.close()
  </code></pre>
  
  <p>The problem is that my code never emit 'readyRead' signal. When I checked it with a simple python client, it worked and read the information so I don't think the problem is with the server. Also, the lines  qDebug() &lt;&lt; "Connected!";qDebug() &lt;&lt; _socket->peerAddress();
  Do print the right address and the server gets the connection. Trying to write to the server also fails, and bytesAvailable always returns 0.
  What am I doing wrong? 
  Thanks.</p>