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
2 answers

QTcpSocket - How to send two numbers

Client Application sends two (ushort) numbers via QTcpSocket to the server: ushort MessageId = 4; ushort MessageSize = 0; socket->write((const char*) &MessageId, sizeof(ushort)); socket->write((const char*) &MessageSize,…
Sora
  • 73
  • 7
0
votes
1 answer

QTcpSocket and QTimer for automatic reconnection best practice

we are trying to implement an application which retrieves data from multiple servers, so we need several QTcpSocket instances in order to manage the connections for each host. We are facing some decisional "design" problems: should we implement a…
0
votes
1 answer

Convert Binary QString to QPixmap

I'm receiving a binary thru FTP and storing it as a QString. The original image was BMP but to pass through FTP I converted it to QPixmap. I'm able to successfully receive this binary but I can't convert back to a QPixmap or some sort of format to…
user8057102
0
votes
1 answer

change Qt GUI by Qt tcp socket?

i have a server and client.i am going to change the handle of my clock to new value that will send by client to server.i added the source code below. my problem is when client connect to server after client send data to server to change the handle…
0
votes
3 answers

Qt: Detect a QTcpSocket disconnection in a console app when the user closes it

My question title should be enough. I already tried (without success): Using a C-style destructor in a function: __attribute__((destructor)): void sendToServerAtExit() __attribute__((destructor)) { mySocket->write("$%BYE_CODE%$"); } The…
user7336312
0
votes
0 answers

Unable to connect to establish a socket connection using QTcpSocket to a linux box (telnet works)

code: watchTowerSocket = new QTcpSocket(); watchTowerSocket->connectToHost("198.168.101.230", 4400); if(watchTowerSocket->waitForConnected()) { qDebug() << "Connected"; watchTowerSocket->write("HELLO SERVER"); } else { qDebug() << "Not…
Chani
  • 5,055
  • 15
  • 57
  • 92
0
votes
1 answer

Passing a QLocalSocket* to a method expecting a QIODevice*

Perhaps I'm being over-ambitious, but I'm trying to write a server program which can accept connections over both QLocalSockets and QTcpSockets. The concept is to have a 'nexus' object with both a QLocalServer and QTcpServer listening for new…
Eos Pengwern
  • 1,467
  • 3
  • 20
  • 37
0
votes
1 answer

Read (many) values from QTcpSocket (fast)

I'm using a measurement device which sends (binary) float values using a tcp socket with up to 70 kHz. My goal is to read these values as fast as possible and use them in other parts of my program. Till now I'm able to extract value by value using a…
Famok
  • 3
  • 4
0
votes
1 answer

Audio file transfer byte by byte in QTCPSocket(Qt-C++)

I need to transfer an audio files byte by byte in socket and in receiver side I need to arrange it properly. For example, there is two audio files A and B, I have to read one byte from A and transfer, next I have to read first byte from B and…
paulraj J
  • 65
  • 6
0
votes
0 answers

QTcpSocket never emits "connected"

I write my TcpServer on Windows 7. Qt 5.7 The server works fine, when i connect with Telnet to 127.0.0.1 and port 4545 TcpServer: _dataChannel = new QTcpServer(this); connect(_dataChannel, QTcpServer::newConnection, this,…
murzagurskiy
  • 1,273
  • 1
  • 20
  • 44
0
votes
0 answers

receive whole data from qtcpsocket

i write this code but unfortunately i cant receive whole data and only receive 1.4 k byte but i should receive 64 K byte. what should I do please help me. QByteArray ba2; ba2.resize(2); ba2[0] = 0x00; ba2[1] = 0xc0; Client…
mehdi
  • 11
  • 1
0
votes
1 answer

read tcpsocket by qt

hi i want to receive data from FPGA by Ethernet with qt. i can write data to fpga but unfortunately i cant receive data. after writing x"c000" to fpga it should send data but my code doesn't woked. i write this code for receive data but i cant…
mehdi
  • 11
  • 1
0
votes
2 answers

Check if received more or less than one message

I need to make simple chat application using QTcpSocket and QTcpServer. I understand I should put message size in the beginning of the message to check message bounds. But how should I handle the cases when application receives only part of the…
Userr
  • 43
  • 4
0
votes
1 answer

Using QTcpSocket for continuous fast usage

I need to implement a client that reads data at 300 Hz (300 samples per second). When working with C sockets, everything was ok accept for the fact that I need to run a continuous while loop to get the data from the server (which blocks the client…
JLev
  • 705
  • 1
  • 9
  • 30
0
votes
0 answers

Qt: create a library to connect to an external resource and use it in different applications

I am trying to implement a library to connect to an external resource and interact with it via an XML-based API. However I don't know how to get all the data before processing it. I am using QTcpSocket on Windows. The way I have to interact with the…
Fred T
  • 23
  • 1
  • 6