Cannot send data with QTcpSocket
Hi,
With Qt 4.8 under win32, I'm trying to send data to a tcp server
Code:
sck.connectToHost(myip, 7800);
if (sck.waitForConnected(8000)==false)
return -1;
Connection works pretty well (I see it on the server)
But now
Code:
ret = sck.write("test data sending");
ret returned 17, cool...
But on server side, I received... nothing !?
(If I do the same thing in "pure" C socket, it works !?)
What am I doing wrong ?
Thanks for you help...
Re: Cannot send data with QTcpSocket
This might be your problem. Does the object live long enough?
Re: Cannot send data with QTcpSocket
Yes I'm sorry, wrong typo... Anyway problem remains :)
Re: Cannot send data with QTcpSocket
I didn't see the typo. But this isn't what I meant.
You created the socket on the stack, which means it gets destroyed at the end of the function. Since sockets are asynchronous, the data might not have been sent already at the moment the socket object is destroyed.
Re: Cannot send data with QTcpSocket
Ok, I put it into a class, same problem
(Even with the debugger I've got the issue)
Thanks...
Re: Cannot send data with QTcpSocket
Try using a network analyzer. This will give you a lot more insight into the actual network traffic.
I don't know what you mean with "Even with the debugger I've got the issue".
Edit: Also try to use the error signal to see if there's an error.
Re: Cannot send data with QTcpSocket
Thanks for you answer,
Indeed I wasn't very clear. It was just to say it wasn't an issue with the stack.
And yes, my last chance is wireshark :)