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
0
votes
1 answer

how to set SO_REUSEADDR on the socket used by QTcpServer?

I have been using a QTcpServer subclass as a http server, but now I need to reuse the server port. I have tried to set ShareAddress | ReuseAddressHint in a QTcpSocket, it seems worked, because the same port can be bound twice. But I did not find a…
YouCL
  • 93
  • 1
  • 3
  • 11
0
votes
1 answer

Slots and signals in Qt C++ in QTcpServer app

There is a question about slots and signals in Qt C++ in QTcpServer app. I am not very familiar with slots and signals approach. So ...the issue is slots for client socket on server app is not being invoked at all. I think that I use connect…
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

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

Can I use QUdpSocket to conect with QTcpServer?

I am super new to the networking world, so I have a QTcpserver that's currently working with the newConnection signal, but I was wondering if I could use QUdpSocket with a QTcpServer ? It's this possible at all ?
SSM89
  • 333
  • 1
  • 3
  • 10
0
votes
1 answer

How to use a QTCPServer in multiple threads?

I am trying to write a webserver that processes requests from multiple clients simultaneously. The way it is designed, only one request can be processed at a time. What I need is a way to call nextPendingConnection() and then dispatch the connection…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
0
votes
0 answers

Sending Structure from TCP Client (NON QT) to TCP Server (QT)

This is my common header file. /*Type of data being sent to HMI*/ enum HMIDataType{ Climate = 0x12 }; #define MIN_DATA_CLIMATE 0x00000200u #define MAX_DATA_CLIMATE 0x000002ffu /*Types of Climate Data*/ enum enumClimateData { //! @brief…
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
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
1 answer

QTcpServer::incomingConnection(qintptr) not calling

I'm trying to make client and server using QTcpSocket and QTcpServer. So, what happens to server. I run the server, it starts listening (successfully [checked by myself]) I run client, enter 127.0.0.1 for IP address and 30000 for port Client says…
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

QTcpServer::hadPendingConnections() returns false upon new connection

I am working on some server application, which skeleton is subclassed QTcpServer, named UeTcpServer. The server app starts normally and when I place breakpoint in ueSlotTcpServerNewConnection(), which is connected to UeTcpServer's…
KernelPanic
  • 2,328
  • 7
  • 47
  • 90
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