A
A
alexey_abramov2015-11-24 23:34:11
Qt
alexey_abramov, 2015-11-24 23:34:11

How to effectively test client-server applications written in Qt on the same machine?

Hello.
I create a client-server application on Qt, the exchange goes through TCP. Online game.
All data is sent to the QTcpSocket of the connected clients.
In fact, if you run the application 2 times on the same computer to test 2 clients, the data will only be sent to 1 client application. Because QTcpSocket is the same.
Is it possible to run applications without using virtual machines so that 2 applications have different QTcpSocket values? Through some setting of Windows / Linux (there is no particular difference on what to test, if only on 1 computer)? And it's too time-consuming to do otherwise.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2015-11-25
@alexey_abramov

the exchange is via UDP

It is not clear what to choose from this.
I didn’t quite understand the meaning of the expression “QTcpSocket value”, but from the point of view of the IP protocol, the operating system, with the standard socket binding method, will identify the socket (and the corresponding application) by the pair (IP address; port). If you do use UDP and the corresponding socket type, then you somehow solve the problem of connecting several clients to the server (in the case of TCP, QTcpServer would do this for you). Depending on the management model you choose, clients either use a fixed UDP port and send datagrams from some IP address and this port, waiting for a response from the server there, or choose a random free UDP port.
In the first case, it is difficult to call clients "clients" because they also hang on a fixed port and are equal to the server from the point of view of the network. To test this case, you can try adding additional IP addresses to your machine, and bind different "clients" to different addresses so that the (address, port) pair is unique.
And in the second case, there should be no problems if the port is chosen randomly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question