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

QTcpSocket gets NULL after QTcpServer::nextPendingConnection()

So I have a QTcpServer here (simplified version of Qt's Fortune Server Example). It was working fine earlier. Then I moved some things around and changed some code. Now my server crashes on start. As far as I can tell, after tcpSocket =…
DDauS
  • 105
  • 1
  • 2
  • 11
0
votes
1 answer

Reading Variable length messages in Qtcp readyRead()

The following code is intended to display an Image sent over network. I sent a header of 16 bytes which I use to calculate the size of image that follows and then read that many bytes and display the image. I used the concept at this link Tcp…
Hanu
  • 57
  • 6
0
votes
1 answer

QTcpSocket readyRead() signal emits multiple times

I'm new to Qt and currently learning to code with QTcpServer and QTcpSocket. My code to process data is like Myclass() { connect(&socket, &QTcpSocket::readyRead, this, &MyClass::processData); } void MyClass::processData() { /* Process the…
Ryan
  • 373
  • 4
  • 15
0
votes
1 answer

Qt convert QTextEdit HTML to QByteArray

I have a QTextEdit where text can be inserted as html. This text needs to be sent over a QTcpSocket. I retrieve the text from the QTextEdit as follows: QString text = ui->message->toPlainText(); socket->write(text.toLatin1().data()); This works…
wasp256
  • 5,943
  • 12
  • 72
  • 119
0
votes
0 answers

Connection problems: TCP Socket with QTcpServer and Android client

I'm trying to make a Socket connection via TCP protocol. But my server (written in C++ and running on my PC) does not receive connection request from my client (written in Java and running on Android) ServerSocket.h (in my PC) class ServerSocket:…
josper04
  • 41
  • 3
0
votes
1 answer

Qt Client received junk characters in addition to expected string

I am implementing a simple Qt based client which sends one command at a time to NON_QT server and server responds back. Once I get a reply from server I use it to for other purposes depending on the response Everything works as expected. Only slight…
samprat
  • 2,150
  • 8
  • 39
  • 73
0
votes
1 answer

QTCPSocket start by timer at the same time

I have problem with synchronize(start at the same time QTCPSocket) in my application I have 10 sockets. I have to read data at the similar time to all sockets. At this moment I have something that: ///.../// if(!socket->waitForConnected(-1)) { …
Szymson
  • 990
  • 1
  • 13
  • 28
0
votes
0 answers

How to wait for Qtcpsocket data without freezing the GUI in Qt?

I have implemented a **QTcpserver ** . After succesfull connection with the client( PLC), both exchange data in a 2 way hand shake. Means Server sends the data with a counter value and client will reply with the same value, the moment server…
vishnu
  • 363
  • 3
  • 20
0
votes
2 answers

How to let QTcpsocket remain connection after closing DialogWindow?

In my Qt application, I have a MainWindow and a DialogWindow. The DialogWindow is for setting up server's IP address and port. While MainWindow is for performing communication after successful connection. However, setting up QTcpSocket *socket in…
Ryan
  • 279
  • 1
  • 4
  • 12
0
votes
2 answers

QTcpSocket Not Connecting

I am trying to setup a QTcpSocket connection. I am working on a simple application that involves bidirectional communication via a single TCP socket. I am testing my code by running two instances of the same application and connecting both to…
mtwister
  • 51
  • 2
  • 5
0
votes
1 answer

Qt creator cannot find, QTcpServer and QTcpSocket

Eventhough, I put 'network' in .pro file, My Qt creator cannot find QTcpSocket and QTcpServer. What should I do? I remove the Qtcreator and redownloaded already but it also did not work. My Linux version is Ubuntu 14.04 LTS and I downloaded QT…
Ray
  • 53
  • 1
  • 7
0
votes
1 answer

Making a client in Qt that tries to connect to server, and if it fails, it keeps trying until it connects

I'm using QTcpSocket for this program. void MainWindow::connectFunction() { socket->connectToHost(ip, port); if(socket->waitForConnected(2000)) { QTime time = QTime().currentTime(); ui->textBrowser->append('[' +…
0
votes
1 answer

QTcpSocket not emit any error or connected signals

I have a small project which send some data over network using QTcpSocket. The server works fine but the client(code here) seems does nothing. If I set breakpoint at tcpSocket.connectToHost("127.0.0.1",port); it does jump in, but not any slots I…
Tiana987642
  • 696
  • 2
  • 10
  • 28
0
votes
1 answer

QTcpServer with android client unable to print or use data received from client

I am developing Client-Server application in C++ using Qt framework, but the clients can be android phones and computers(Qt client app) Now i'm having troubles to handle Reception of data on the server side; the server is not receiving data…
Xsmael
  • 3,624
  • 7
  • 44
  • 60
0
votes
1 answer

QTcpServer - how to multi-thread - example is bad

I'm trying to make QTcpServer start a separate thread for each connection. There's example code available that does just that: http://doc.qt.io/qt-5/qtnetwork-threadedfortuneserver-example.html This code works by subclassing QThread. If I build my…
Philipp
  • 957
  • 1
  • 6
  • 20