I want to create a RCON-sender in C++ for Jedi Academy Multiplayer Game. Everything works fine, only problem is that, when I read recv()
from server, the order is not corrent sometimes!
std::vector<std::string> ReceiveLine() {
std::vector<std::string> ret;
char* r = new char[1024];
int i = 0;
while (i < 40) {
for(unsigned int j=0; j<1024; ++j) r[j]=0;
if (recv(s_, r, 1024, 0) <= 12) {
break;
}
ret.push_back(r+10);
++i;
}
return ret;
}
It prints like this:
map: mp/ffa3
num score ping name lastmsg address qport rate
4 0 0 Alora 33 bot 6145 16384
5 0 0 Alora 33 bot 22058 16384
6 0 0 Alora 33 bot 60636 16384
7 0 0 Alora 33 bot 18312 16384
8 0 0 Alora 33 bot 11812 16384
--- ----- ---- --------------- ------- --------------------- ----- -----
0 0 22 test 0 XX.XX.XXX.XXX:29070 65099 25000
1 0 0 Alora 33 bot 9234 16384
9 0 0 Alora 33 bot 27681 16384
10 0 0 Alora 33 bot 19116 16384
11 0 0 Alora 33 bot 3514 16384
2 1 0 Alora 33 bot 65099 16384
12 0 0 Alora 33 bot 5972 16384
3 0 0 Alora 33 bot 41129 16384
13 0 0 Alora 33 bot 30716 16384
It should be in order by num (Works in PHP)
UDP does not guarantee ordered delivery. There are lots of reasons why a datagram might arrive out of order.