That will be a plan for future, as a 1-st step it's easier to send packets all the time.
And it causes disconnect, no idea why, but that's unacceptable behavior even if i sent them in wrong time and to wrong ips
This is actually a good sign. Causing the disconnect means that the packets are ending up where they should be... --> they are going to the WC2 client.
Of course at this point what you are making is a disc-bot, because you are sending the client rubbish packets - in this case "For the Alliance" which is clearly causing a problem for the client.
I discussed this in September 2016 when I first posted this solution:
The packets can be anything. Null packets would probably work fine, whatever, as long as it doesn't crash the client with garbage, its all good. We have then done our “lat trick” between the host and the joining client which is the only one not already being done. End of hosting issues forever. GG
I can quite easily help you with code that will let you detect when the client is hosting a game, and not in the channel or in game, that is very simple.
It will be up to you to make sure that your address list has ONLY the players in the channel, not those in games, otherwise you could possibly disconnect other people playing or contribute to game lag.
Sending out packets all the time to everyone is a bad idea, for a lot of reasons, not the least of which is that you are opening up your own firewall to everyone on the server for no reason. People could drop-hack you from games while they are in the channel or worse.
-- edit --
Do you see that we dont need to know the remote port? Only use the local game port as both the source and destination
Which is the reason you can't get it to work through symmetric NAT. Why not just do it properly?
I think just standard 'socket' 'connect' and 'sendto' etc. should do it for anything I've been talking about..
I'm a bit busy working on another project right now, but when I get some spare time I'll fix it for you if the 'expert' hasn't worked it out by then