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
72
votes
8 answers

How to find Version of Qt?

How do I know which version of Qt I am using? When I open Qt Creator it shows "Welcome to Qt Creator 2.3". In the build setting, however, it shows Qt Version 4.7.1.
user3472783
  • 743
  • 1
  • 6
  • 7
29
votes
7 answers

How to make sure that readyRead() signals from QTcpSocket can't be missed?

When using QTcpSocket to receive data, the signal to use is readyRead(), which signals that new data is available. However, when you are in the corresponding slot implementation to read the data, no additional readyRead() will be emitted. This may…
Misch
  • 10,350
  • 4
  • 35
  • 49
26
votes
4 answers

QTcpSocket state always connected, even unplugging ethernet wire

I have a QTcpSocket and I am reading into a loop. Each time a full packet has been read, or there has been an error, I manually check the status of the socket inside the loop, with: while(true){ …
Roman Rdgz
  • 12,836
  • 41
  • 131
  • 207
11
votes
3 answers

C++ Qt - QTcpSocket - File not found

I am using Qt and QTcpSocket to create a small chat client/server application. When I compile my code, the compiler returns the following error: main.cpp:3:22: fatal error: QTcpSocket: No such file or directory This refers to #include…
Béatrice Moissinac
  • 934
  • 2
  • 16
  • 41
10
votes
1 answer

Behavior of QTcpSocket::waitForBytesWritten?

I'm a little confused on the behavior of QTcpSocket::waitForBytesWritten()... Until when does this function block? Until the data is written to the OS's internal buffer for transmission over TCP? Until the data is physically converted to TCP…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
10
votes
5 answers

QTcpSocket client auto reconnect

I'm trying to write a piece of code that periodically tries to connect to the server using QTcpSocket until the server is up and ready. The client should also automatically and periodically try reconnecting when the server is down until it is up…
Furkan
  • 683
  • 2
  • 10
  • 26
9
votes
4 answers

Read from QTcpSocket using QDataStream

I need to send binary data through a QTcpSocket. I was thinking about using QDataStream, but I've encountered a problem - it silently fails if no data has arrived at the time I try to read. For example if I have this code: QString str; stream >>…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
8
votes
1 answer

Move QTcpSocket to a new Thread after the connection is initiated

I've got a threaded server. QTcpSocket needs to be created on the thread it needs to be ran on, FI: Qt - Handle QTcpSocket in a new thread by passing the socket descriptor. My problem is that, I need to have a pool of thread and move the socket on a…
Damien
  • 1,492
  • 10
  • 32
7
votes
1 answer

QSslSocket: cannot resolve SSLV2_client_method

I have created a sslclient and sslserver using QSslSocket in Qt 5.4.1 in debian wheezy. When I run the program they dont work at all. After debuging my code I saw when it try to create a new object from QSslSocket it return this error (cannot…
Ehsan Maiqani
  • 1,684
  • 1
  • 14
  • 16
7
votes
4 answers

How to read complete data in QTcpSocket?

Now the server (implemented with java) will send some stream data to me, my code is like below: connect(socket, SIGNAL(readyRead()), this, SLOT(read_from_server())); in the read_from_server(): { while (socket->bytesAvailable()) { …
yakiang
  • 1,608
  • 1
  • 16
  • 17
6
votes
1 answer

Get remote host Ip address QTcpServer

I'm using Qt to create TCP server using QTcpServer. Every time a client connects to server, I would like to know the remote host's IP address and port number. I tried searching documentation but couldn't find any information on this topic. I know…
nik
  • 8,387
  • 13
  • 36
  • 44
6
votes
1 answer

Qt: default connection timeout for QTcpSocket

Please advise how can I setup default connection timeout without using blocking waitForConnected() method? I noticed that socket emit error signal (QAbstractSocket::SocketTimeoutError) after about 60 seconds that I can handle as a timeout, but can…
user3948829
6
votes
1 answer

Implementation of Qt's QTcpSocket ReadyRead signal

I want to know about Qt's implementation of QTcpSocket's ReadyRead signal. How is it implemented on Windows and on Linux? Using select(), poll(), epoll(), SIGIO or any other way? How does QTcpSocket know when to emit a ReadyRead signal?
rick
  • 119
  • 1
  • 3
6
votes
1 answer

Morph existing QTcpSocket to QSslSocket

Is it possible to create a new QSslSocket and for it to take ownership over the existing TCP connection, and the old QTcpSocket to be discarded, without interrupting or closing the TCP connection? I need this to implement explicit FTPS in my FTP…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
5
votes
2 answers

PyQt QTcpServer: How to return data to multiple clients?

I am looking to create a QTcpServer using PyQt that can simultaneously return data to 2 or more clients. I assume that this will require threading. Using the threadedfortuneserver.py example as a test case (included with PyQt4, on my system it is…
XandYandZ
  • 283
  • 1
  • 3
  • 9
1
2 3
20 21