qtcpserver

how to set SO_REUSEADDR on the socket used by QTcpServer?

爱⌒轻易说出口 提交于 2020-01-03 05:16:19
问题 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 way to get a QTcpSocket object from an existing QTcpServer object. I also used the socketDescriptor() to get the native socket, because I want to use the linux C way to setsockopt , but I don't know how to use linux C code with Qt code together to

PyQt5: Sending and receiving messages between client and server

∥☆過路亽.° 提交于 2020-01-01 19:27:17
问题 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 PyQt5.QtNetwork import QTcpSocket class Client(QDialog): def __init__(self): super().__init__() HOST = '127.0.0.1' PORT = 8000 self.tcpSocket = QTcpSocket(self) self.tcpSocket.connectToHost(HOST, PORT, QIODevice.ReadWrite) self.tcpSocket.readyRead

Qt using threadpools, unable to recieve all the data at once in readyRead()

六眼飞鱼酱① 提交于 2019-12-23 04:41:46
问题 I'm a newbie in QT and C++, I'm trying to create a QTcpserver using QThreadpools so it can handle multiple clients. Multiple clients are able to connect without any issues. But I'm trying to send an image from an android phone, with a footer "IMGPNG", indicating the end of image data. Now the issue when the readyRead signal is emitted I'm tring to read all the data available data and then perform some string operation later and reconstruct the image. I'm not sure how to receive the complete

Qt using threadpools, unable to recieve all the data at once in readyRead()

≡放荡痞女 提交于 2019-12-23 04:41:04
问题 I'm a newbie in QT and C++, I'm trying to create a QTcpserver using QThreadpools so it can handle multiple clients. Multiple clients are able to connect without any issues. But I'm trying to send an image from an android phone, with a footer "IMGPNG", indicating the end of image data. Now the issue when the readyRead signal is emitted I'm tring to read all the data available data and then perform some string operation later and reconstruct the image. I'm not sure how to receive the complete

How to Create a HTTP MJPEG Streaming Server With QTcp-Server Sockets?

倖福魔咒の 提交于 2019-12-17 13:26:32
问题 I want to create a Http Server to send an MJPEG Stream. I'm Already able to send an Image but no Live-Stream. What I did: Created an TCP-Server. When a client Connects a TCP-Socket is created. Then I implemented a ReadyRead SLOT which gots executed when the Browser sends the "GET" Request to the Server. GET / HTTP/1.1 Host: 127.0.0.1:8889 User-Agent: Mozilla/5.0... Then I run following Code QString inbound = m_Client->readAll(); QByteArray header = "HTTP/1.1 200 OK\r\n"; m_Client->write

When subclassing QTcpServer, how can I delay emitting the newConnection() signal?

雨燕双飞 提交于 2019-12-13 01:09:04
问题 I want to create an SSL server, so I subclass QTcpServer and I override incomingConnection() , where I create a QSslSocket , set its descriptor, and call QSslSocket::startServerEncryption . At this point I need to wait for QSslSocket::encrypted() signal to be emitted, and only after that should my server emit the newConnection() signal. The client code would then think it's using a QTcpSocket, but will in fact be using a secure socket. But QTcpServer always emits newConnection() after calling

QTcpSocket connecting results in UnknownSocketError with errorString “UnknownError”

半腔热情 提交于 2019-12-12 03:49:03
问题 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 value = -1 Calling QTcpSocket::errorString() provides this: "Unknown error" There is one question regarding this here on SO but provides no real solution to solving the issue (and what was suggested I have done) I have absoltely no idea how to further

Get remote host Ip address QTcpServer

两盒软妹~` 提交于 2019-12-10 13:20:12
问题 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 there should be a way, I'm just not able to figure it out. Help please. 回答1: QTcpServer won't tell you the address/port directly on an incoming connection but you can get it by getting the connected QTcpSocket from QTcpServer::nextPendingConnection()

Programm crashes when QTcpServer is called

杀马特。学长 韩版系。学妹 提交于 2019-12-08 04:02:39
问题 I'm trying a very, very simple QT networking program. For some reason it crashes when executing without any error message, since it's not printing out any of the outputs to the command line as expected. Here's the code: qtTCPservertest.pro QT += core QT += network QT -= gui TARGET = qtTCPservertest CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp \ theserver.cpp HEADERS += \ theserver.h theServer.h #ifndef THESERVER_H #define THESERVER_H #include <QTcpServer> #include

PyQt QTcpServer: How to return data to multiple clients?

泪湿孤枕 提交于 2019-12-03 10:09:12
问题 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 found in /usr/share/doc/python-qt4-doc/examples/network), I want to connect multiple clients and each time one of the clients asks for a fortune, the other clients also get updated with a message like "Client X just received the fortune 'blah blah