Qt 4.7.4, linux and windows.
Issue: QTcpServer does not execute incomingConnection nor emits/receives newConnection when child QTcpServers are running.
How it works now: There are 3 instances of the QTcpServer class running, bound to 3 different ports. pServer2A and pServer2B (CServer2 instances) are running continuously serving a big number of incoming requests (continuously running 20-30 threads/connections each). The object created from class CServer1 works fine as long as there is no or minimal load on pServer2A and pServer2B. However, if those are busy then it often times out or does not receive any incoming connection after quite a while (sometime for over a minute). It looks that there is a relation between the load of the two child QTcpServer based instances and that setMaxPendingConnections (and the number of maximum pending connections) is applied as composite in Qt.
Does anybody know an explanation why this is happening and how to fix it? FYI, QTcpServer objects are created with null parent so there shall be no relationship between those instances really.
Question: Can business of child instances make parent QTcpServer stuck? Do those share the TCP backlog and/or message backlog at all? Any suggestion
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
class CServer1 : public QTcpServer {
Q_OBJECT
// ...
private:
CServer2 *pServer2A, *pServer2B;
protected:
void incomingConnection(int SocketDescriptor); // Executed if pServer2A and pServer2B are not really busy, otherwise times out
/*private slots:
void NewConnection();*/ // This too, just like above
};
class CServer2 : public QTcpServer {
Q_OBJECT
// ...
protected:
void incomingConnection(int SocketDescriptor);
};
int main(int argc, char *argv[]) {
CServer1 Server;
// ...
// Server1.listen, etc are all good
}
|