When I tested the code yesterday, I found a very strange problem, in the lab, I run the server on a server, with my classmate's computer running the client is completely normal. But when I test the code at night in the dorm, one computer runs the client and the server, and the other runs the client, but it's always an exception, the same code, why the results are different?
The client is a multi-to-many audio and video call, the server side assists the connection. The experimental results of the dormitory are two cases ① two clients die as long as the connection is ② one client receives its own audio and video, while the other client always shows that the audio and video stream is occupied. In particular, the second phenomenon is very inconsistent with common sense! Two clients are equivalent, how to experiment phenomenon will appear different?!
Later, I looked through the stream of SDP file records, found that some of the IP address is 127.0.0.1, and some appear:: 1 such an IP address. In retrospect, I originally ran the client on the machine that had served as the server, in order to save trouble, sometimes the IP was set to 127.0.0.1, sometimes simply set as localhost.
When the host to which the client is connecting is localhost, the address string in the client TCP link pointer obtained by the server side Qtcpsocket *->peeraddress () should be ":: 1".
When the host is "127.0.0.1", the server side gets the address string of the client TCP link pointer qtcpsocket *->peeraddress () Unexpectedly is also "127.0.0.1", these two cases is not the real IP address at all.
Figures:
[Qt] Qtcpsocket get the IP address small bug