Home > other >  The small white on UDP broadcast was shown some of the problems.
The small white on UDP broadcast was shown some of the problems.

Time:03-09

Various bosses, everybody!

I now use QT wrote a program that is similar to QQ, communications between the client USES the udp,

If I run two programs at the same time, also is in two accounts, between them is to use unicast or broadcast message? I learned unicast need to specify the IP address and port, but because I have only one host, IP address is the same, I don't think I'm done unicast, (if you can use unicast, bosses, please give directions) I will try to broadcast on try,

Now, I am using the broadcast message, landing each client according to the different port of account Settings, account after four, for example, if the port number are not identical, and B wants to send A message, click on the head of A, access to A port number, in the chat window (specifies the port number) of transmitting radio,
For example, udpSocket - & gt; WriteDatagram (data, the data length (), QHostAddress: : Broadcast, 8889);

A after landing has been monitored their ports, can read messages as message came in, but the question now is not sure who is sent, is B can send A message, A also can receive, but don't know who sent,
But I again because there is only one host, only one IP, there are currently no ideas do specify the IP address unicast, could you tell me how to solve the problem requires?

For now use the radio, I want to have an idea, if radio message, can in the messages sent, on his own account, because I do the comparison of crude code, friends set up to 10, the account is the only sure, can you receive a message, after parsing, read the account, then judge which one is good friend hair message, can not only read the port number the message in the chat window, display messages do not take account again,

CodePudding user response:

Added: I think of the same computer can log on to the two QQ accounts, the communication between them is what kind of? Both the IP address of the qq won't be the same? Because learning is not enough, there are many places not enough understanding, also hope the teachers glad,

CodePudding user response:

UDP sends data, data will contain the IP source address and source port?

CodePudding user response:




Can get to the source IP address and port now but it just send the "1", why show those things?
  • Related