Questions tagged [qtcpserver]

QTcpServer is a Qt class embedding a TCP-based server.

The QTcpServer class provides a TCP-based server.

This class makes it possible to accept incoming TCP connections. You can specify the port or have QTcpServer pick one automatically. You can listen on a specific address or on all the machine's addresses.

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

140 questions
1
vote
1 answer

Reading from QTcpSocket fails if QTcpServer has not been closed

Here is a simple minimal working example that reproduces behavior I find weird (probably due to my misunderstanding of something): main.cpp #include #include "dialog.h" int main(int argc, char *argv[]) { QApplication app(argc,…
Maximko
  • 627
  • 8
  • 20
1
vote
2 answers

Qtcpserver return unknown error on listen function only under debugger

When I try to listen on any port with QTcpServer, and run app under debugger, I always get 'Unknown error'. When I run this program without debugger - all seems good. #include #include #include int main(int…
murzagurskiy
  • 1,273
  • 1
  • 20
  • 44
1
vote
1 answer

QTcpSocket data arrives late

I am using QTCPSockets to talk to a program I've written in Qt for Raspberry Pi. The same software runs on my Mac (or Windows, whatever). The Pi is running a QTCPServer. I send JSON data to it and most of the time this goes ok. But sometimes, the Pi…
Boy
  • 7,010
  • 4
  • 54
  • 68
1
vote
1 answer

QTcpServer: how to return value?

I'm writing Client/Server communication system on Qt. I'm using QTcpServer and QtcpSocket. I'm sending some information from client side but how can I return value from server? Client Side QTcpSocket *socket = new…
Leri Gogsadze
  • 2,958
  • 2
  • 15
  • 24
1
vote
1 answer

How to compare IP of the requested client connection to one of the recognized IP's in QTcpSocket class?

My main issue is: I have a list of recognised IPs and I am carrying out Multi threaded TCP Client-Server Communication; so whenever a new connection request comes from any random client (server is constantly listening), I want to first compare that…
Shahwani
  • 15
  • 8
1
vote
3 answers

QTcpSocket::readAll() is empty

I am new to Qt and am in a bit of a struggle. I am trying to send a string from a client to a server using QTcpSocket. Client side: QByteArray block; QDataStream out(&block, QIODevice::WriteOnly); out.setVersion(QDataStream::Qt_4_0); out <<…
1
vote
1 answer

Can I connect two QTcpSocket in different networks?

Can I connect between only local machine or can connect to another network?
Roman
  • 11
  • 3
1
vote
2 answers

QTcpServer retrieve more than one address

I use QTcpServer from the Qt-Framework with C++. I started it with ret = tcpServer->listen(QHostAddress::Any, 9871) With QHostAddress serverAddress () const I retrieve the Address from it. Which is 0.0.0.0. In my opinion it should listen on more…
Herrbert
  • 113
  • 1
  • 2
  • 9
1
vote
1 answer

PyQt5: Sending and receiving messages between client and server

I am trying to create a server and client to send and receive messages. My problem is to send and receive between the client and the server. client.py: from PyQt5.QtCore import QIODevice from PyQt5.QtWidgets import QApplication, QDialog from…
Mahmoud Anwer
  • 164
  • 1
  • 2
  • 12
1
vote
2 answers

QTcpSocket in QThread will commitTransaction but when Write is called "Cannot create children for a parent that is in a different thread."

Disclaimer: I am relatively new to Qt and any type of programming that revolves around Threads and Networking. I have also adopted a lot of code from Qt Examples, API, and other online examples. All code can be found on GitHub. This code is…
Mason R
  • 51
  • 6
1
vote
1 answer

QTcpSocket unknown error

I want to send data from client to server, when i try to connect to serevr, client show unkown error, and no data sent its show only empty string "", any help will be appreciated. here is the code: //client Widget::Widget(QWidget *parent) : …
abdallah allam
  • 73
  • 1
  • 13
1
vote
1 answer

How to send and read string lines via QTcpSocket?

I try to send strings from client to server line by line in a foreach loop: foreach(QString s, stringlist) client.sendMessage(s); But the client receives only first string. When I remove "\n" from a string, server receives a bunch of strings…
lena
  • 1,181
  • 12
  • 36
1
vote
1 answer

QTcpServer receiving and sending in a different thread

I have a piece of software in QT framework (c++) that's suppose to dispatch processed (local) data to other servers and receive the same (foreign) data processed on other servers and compare it. Problem occurs when a large amount of local data is…
Anže
  • 181
  • 8
1
vote
1 answer

QtNetwork: Why don't I detect incomming connections ? (incomingConnection() is never fired)

I sticked to the tutorial about threaded qt-networking (which is here: http://doc.qt.io/qt-5/qtnetwork-threadedfortuneserver-example.html), I made some minor changes and integrated it into my main program. However incomingConnection() never gets…
user3085931
  • 1,757
  • 4
  • 29
  • 55
1
vote
1 answer

qt qtcpserver is only working when it is created in main function

I just wrote a simle qtcpserver, which is nearly this example: QT QTcpServer::incomingConnection(qintptr handle) not firing? The server is basically working, but only when it is created within the main function. working: int main(int argc, char…
cwly
  • 13
  • 4
1 2
3
9 10