[Interest] problem receiving data from QTcpSocket

Guido Moonen info at tngsoftware.nl
Wed Nov 2 14:21:42 CET 2011


Hello,

Still not sure which protocol you are using to communicate port 110 should be POP3 and what you are sending does not look like POP3 :)

But for debugging.

Maybe you could try this snippet of code which does the communication in a single process without going to the event loop:

  QTcpSocket *mSock = new QTcpSocket();
  mSock->connectToHost("<some_host>.com", 110);
  if (mSock->waitForConnected(2500))
  {
    int wCount = mSock->write("b_action=check;b_version=something;b_device=TestDevice\n");
    if (wCount != -1)
    {
      /* not sure if this function should return true or false */
      mSock->waitForBytesWritten(2500);
      if (mSock->waitForReadyRead(2500))
      {
        QByteArray ba = mSock->readAll();
        qDebug() << "Received reply: " << ba.length() << ba;
      }
      else
      {
        qDebug() << "Failed to receive data";
      }
    }
    else
    {
      qDebug() << "Failed to write to host..";
    }
  }
  else
  {
    qDebug() << "Failed to connect to host..";
  }

Disclaimer: I have not tested this code if it works. But it should shine a light on what is happening..

TNG Software
van den Hummelstraat 34
5175 CM Loon op Zand
info at TNGSoftware.nl
06-26912345


On Nov 2, 2011, at 14:00 , sarvesh saran wrote:

> H
> 
> On Wed, Nov 2, 2011 at 6:21 PM, Guido Moonen <info at tngsoftware.nl> wrote:
> Hi,
> 
> Which protocol are you using to communicate on this port? I cannot find the official use for port 114.
> 
> Thank you for your answer.  Its port 110. (sorry for the Typo).
> 
>  
> 
> But I would think it needs "windows" enters ("\r\n") instead of just the normal "\n"
> 
> \r\n does not help either.
> 
>  
> 
> And if this does not help do you use a raw socket in putty or a terminal one?
> 
> I use a terminal one ( there are 5 options in Putty: "raw", "telnet", "rlogin", "ssh" and "serial"). I always pick "telnet" and it works.
> 
> 
> 
> thanks,
> Max
> 
> 
> On Nov 2, 2011, at 13:40 , sarvesh saran wrote:
> 
>> Hi!
>> 
>> I am writing a really simple test application that has to connect to a remote server, send some data and read the reply back.
>> 
>> I've created a QTcpSocket, and then used the connectToHost() call to connect to the server.
>> 
>> The connection is successful and I get the connected() signal.
>> 
>> Now, when I write data to the server, I never really get a reply (even though the write was successful). I don't get an error either. 
>> 
>> However I do get a reply if I connect and send the data to the server through Putty! So I am not sure what I am doing wrong.
>> 
>> The code is really simple:
>> 
>> sock->connectToHost("<some_host>.com",114,QIODevice::ReadWrite);
>> 
>> and then in the slot ( slot is for the connected() signal):
>> 
>> int w = sock->write("b_action=check;b_version=something;b_device=TestDevice\n");
>> 
>> At this point I keep waiting for the readyRead() signal which never comes. However, a Putty session with the remote server works fine and I can see the servers reply.
>> 
>> How do I go about debugging this issue? I am really clueless at this point. Is there a fault with the server?
>> 
>> thanks,
>> max.
>> 
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20111102/a2506535/attachment.html>


More information about the Interest mailing list