Questions tagged [qtcpsocket]

The QTcpSocket class, part of the Qt framework, provides a TCP socket.

TCP (Transmission Control Protocol) is a reliable, stream-oriented, connection-oriented transport protocol. It is especially well suited for continuous transmission of data.

QTcpSocket is a convenience subclass of QAbstractSocket that allows you to establish a TCP connection and transfer streams of data.

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

301 questions
0
votes
1 answer

Qt QTcpSocket streaming

My application sent object to the server via QTcpSocket. Client: void client::sendFile(QString path) { QFile toSend(path); QByteArray rawFile; rawFile = toSend.readAll(); QDataStream out(cl); out >> rawFile; } Server: void…
WildDev
  • 2,250
  • 5
  • 35
  • 67
0
votes
1 answer

QTcpSocket, can't read incoming data

I try to write simple server, using Qt and C++. Here is code: #include "mytcpserver.h" MyTcpServer::MyTcpServer(QObject *parent) : QObject(parent) { server = new QTcpServer(this); // whenever a user connects, it will emit signal …
Robert
  • 371
  • 1
  • 5
  • 15
0
votes
1 answer

Qt Client-server app, “send image” having problems

I am trying to send an image (OpenCV Mat) from client to server over a QDataStream. The first item is an int, the size of the buffer. It works for 10 to 15 images, then the server reads the first int a random number (usual ~2^30) which causes the…
cristiprg
  • 103
  • 1
  • 9
0
votes
1 answer

How to use QTcpSocket instance multiple times with couple second intervals?

I have to repeat the same request with QTcpSocket multiple times with a couple seconds intervals. Easy task but I can't get it to work with only one instance of object. How to connect to server again using the same instance of QTcpSocket? I've tried…
user1598527
  • 5
  • 1
  • 8
0
votes
1 answer

QT QTcpSocket miss some data after start write data to server

I get sine wave from server though TCP and plot it. Everything seems to be fine until I start sending something back at c>1000. After one byte sent, I still get data but the waveform of sine wave is changed. I'm sure that there are some missed data…
0
votes
1 answer

How to send multiple information trought QTcpSocket at the same time?

im doing a small client/server reservation app and im stuck on how i can send the information of the classes, Actually i have 3 classes and im sending the information like this: VentanaPrincipalS::VentanaPrincipalS(QWidget *parent)…
joseluiselp
  • 172
  • 1
  • 12
0
votes
1 answer

Qt5 QTcpSocket derived class and QTcpServer

I'm developing an application that made sense that I wrapped my classes around the implemented QTcpSocket (since it's a TCP protocol, and I need to be able to use the raw socket and the added features as seemlessly as possible). So, for the sake of…
OzBarry
  • 1,098
  • 1
  • 17
  • 44
0
votes
1 answer

QSocketNotifier warning -- using socket inside a thread

I am able to remove this warning, please suggest on below points. QSocketNotifier: socket notifiers cannot be enabled from another thread Whenever new request comes to QTcpServer i create new object -- xxx . This object then create thread for this…
Katoch
  • 2,709
  • 9
  • 51
  • 84
0
votes
1 answer

QTcpServer -- how to stop client threads

My gui have a two button's, one to start a server & other to stop a server. Brief :--- Once server is started, on every new client request i will create a new thread & this will handle communication with the client. Detail :-- When start button is…
Katoch
  • 2,709
  • 9
  • 51
  • 84
0
votes
0 answers

QTcpSocket::connectToHost() crashing on windows XP

I made a program that connects a QTcpSocket to a QTcpServer and it works fine on windows 7 but with windows xp it never connects and the program just closes bool socket::connectToServer(QString ip){ s->connectToHost(ip,1234); …
Ben
  • 470
  • 1
  • 6
  • 18
0
votes
1 answer

Qt/C++ QTcpSocket causes memory leak, not sure why

I am creating a simple(ish) telnet server and am now debugging with valgrind. the code runs great, but valgrind complains about memory lost when the program terminates...and the culprit is the line where I create a new QTcpSocket: void…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
1 answer

Qt/C++/Valgrind Invalid Readsize of 8 on QTcpSocket disconnect

I'm running valgrind on my Qt/C++ program and am getting this error: Invalid read of size 8 in TelnetConnection::disconnectClient() in telnetserver/telnetconnection.cpp:188 and line 188 is the waitForDisconnected line below: void…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
1 answer

Qt endl looks great from linux telnet, wrong from windows telnet

I am building a telnet server app in Qt, and when I connect from a linux telnet client output looks great. For example, sending "A" << endl << "B" << endl << "C" to my console looks like: A B C Now when I connect from a Windows telnet client I…
TSG
  • 4,242
  • 9
  • 61
  • 121
0
votes
1 answer

Not all QMessageBox's in the same function actually show up

This is part of a basic QtCreator code in C++ for TCP client-server communication. This is supposed to be the last function I need to get working. But to understand how this works and where the errors are, I am trying to show a whole bunch of…
DDauS
  • 105
  • 1
  • 2
  • 11
0
votes
1 answer

Memory leak in QTcpServer attending connections in different thread

I'm developing a RPC server in Qt 4.7 on Windows 7. In order to attend several executions at the same time every request run in a separate thread (as functions might be blocking). I inherited from QTcpServer and reimplemented the incomingConnection…
pablo
  • 75
  • 4