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

How do I read a class object from a QTcpSocket using a QDataStream?

I have a class defined by me, say MyClass. I would like to send an object of this class through a QTcpSocket. This answer suggests using a QDataStream, and this shows how the << and >> operators can be overloaded to achieve this. I have so far…
GoodDeeds
  • 7,956
  • 5
  • 34
  • 61
0
votes
1 answer

QTcpSocket connecting results in UnknownSocketError with errorString "UnknownError"

Problem I am unable to get any further information regarding this error: QAbstractSocket::UnknownSocketError The QT QAbstractSocket::SocketError provides only a basic explanation that some error has occurred An unidentified error occurred. enum…
CybeX
  • 2,060
  • 3
  • 48
  • 115
0
votes
0 answers

QAbstractSocket::UnknownSocketError provides errorString of "UnknownError"

I am unable to get any further information regarding this error: QAbstractSocket::UnknownSocketError The QT QAbstractSocket::SocketError provides only a basic explaination that some error has occured An unidentified error occurred. enum value =…
CybeX
  • 2,060
  • 3
  • 48
  • 115
0
votes
0 answers

Qt - How to add QTCPSocket to the pending connections of QTCPServer

I have a simple multithreading application that works like the example "Threaded Fortune Server Example" on Qt website. When my QTCPServer receive an incoming connection, I create a QRunnable task, passing the socketDescritptor and then submitting…
BEPP1
  • 945
  • 2
  • 11
  • 15
0
votes
0 answers

QTCP Server is not sending message to client

Hi I have created a tcp server with Qtcpsocket in pyqt4. I am easily receiving the messages from clients. but this server fails to send messages to client. Please let me know where i am doing wrong. def sendMessage(self): print('send…
Zavi
  • 1
  • 4
0
votes
1 answer

how to write one string at time using qtcpsocket?

How to send string using Qtcpsocket, when using tcpsocket->write("hello"); tcpsocket->write("world"); etc.. tcpSocket->flush(); tcpSocket->waitForBytesWritten(3000); it send it in one string "hello world", what i want make it write only one at…
abdallah allam
  • 73
  • 1
  • 13
0
votes
1 answer

How to use signals and slots in threaded Qt-networking?

I have some trouble with QTcpSockets in combination with Threads. I guess I have misunderstood the documentation regarding Threads, maybe you can explain where my mistake lies. What part should go into the run() method, and when a signal is emitted…
user2567875
  • 482
  • 4
  • 21
0
votes
2 answers

I don't understand what exactly does the function bytesToWrite() Qt

I searched for bytesToWrite in doc and that what I found "For buffered devices, this function returns the number of bytes waiting to be written. For devices with no buffer, this function returns 0." First what does mean buffered devices. And can…
Loui Smith
  • 93
  • 1
  • 7
0
votes
0 answers

Qt: Differenciate between messages received using readAll()

I have a client in Qt that is continuously writing data using QTcpSocket->write( ) method. In the other hand, my server uses QTcpSocket->readyRead() signal which is a connected to a slot that uses readAll() method to retrieve the information. My…
Javi Ortiz
  • 568
  • 1
  • 7
  • 22
0
votes
1 answer

When creating a QTcpServer that allows for multiple connections, why do I need to make a socket in a new thread?

I'm using Qt 5.6. I'm working on a simple chat application and came across several places online all saying you have to create a new thread to contain QTcpSocket to handle all the new connections in a new thread. I'm trying to figure out why you…
Flare Cat
  • 591
  • 2
  • 12
  • 24
0
votes
0 answers

Qt TcpSockets: SIGNAL disconnected timeout

I'm useing QTcpSocket class to communicate between my QT-UI and my PLC. Recently I changed my protocols, so that I can send large coherent chunks of data. The goal is to send string-data via TCP-protocol. On the PLC-Side I delay the sending of the…
J.Hilk
  • 1
  • 3
0
votes
1 answer

An error ouucrred while I calling the write function of the QTcpSocket class from a QThread

I am learning about Multi-threaded programming in Qt, and then while I'm calling the write function of the QTcpSocket class from a QThread.The function output is: QObject: Cannot create children for a parent that is in a different thread. (Parent is…
FancyBirds
  • 11
  • 8
0
votes
1 answer

How to write data immediatly to socket without using flush and waitFOrBytesWritten with QTCPSocket

In my application, While writing to socket the data is not written immediately. But if i use the flush() or waitForByteWritten(msec) then it get written. But here the only problem with flush() and waitforByteWritten() is its creating a performance…
0
votes
0 answers

QTcpSocket - increase send length

I have problem that I only get 16 bytes from my QTcpSocket where I obtained transmission Client-server. I would like to have ability to send more data at one time ( longer than 16 bytes). I send data by (length is here about 33): …
Krzysztof Bieda
  • 187
  • 1
  • 2
  • 10
0
votes
0 answers

Parse JSON from QTCPSocket data

QTCPSocket data contains HTTP header and JSON. How to parse only JSON from this? POST / HTTP/1.1\r\nContent-Type: application/json\r\nContent-Length: 208\r\nConnection: Keep-Alive\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language:…
Kesantielu Dasefern
  • 266
  • 1
  • 3
  • 12