MegaGlest / megaglest-source

MegaGlest real-time strategy game engine (cross-platform, 3-d)
http://megaglest.org/
344 stars 89 forks source link

allow ipv4 and 6 connections #246

Open andy5995 opened 1 year ago

andy5995 commented 1 year ago

(closes #245)

andy5995 commented 1 year ago

At this point (https://github.com/MegaGlest/megaglest-source/pull/246/commits/4dd5e1289cdf94a5b4651f8f6e069b52a096d6c7), I can create a host with no crashes, it shows up on play.mg, but it doesn't actually listen for connections:

*ERROR* [2022-08-13 10:52:01] In [/home/andy/src/megaglest-source/source/glest_game/network/connection_slot.cpp::update Line: 1441] Error [Error creating socket (Error: 97 - [Address family not supported by protocol])
andy5995 commented 1 year ago

I squashed all my commits and did a little bit of clean-up.

No crash when clicking "host game", but server can't broadcast (wrong firewall setup)

So probably the next function to futz with will be void BroadCastClientSocketThread::execute() on L2199

andy5995 commented 1 year ago

I squashed all my commits and did a little bit of clean-up.

No crash when clicking "host game", but server can't broadcast (wrong firewall setup)

I see the problem now. I just constructed the socket wrong (and probably removed too much of the old code).

http://www.microhowto.info/howto/listen_for_and_accept_tcp_connections_in_c.html

andy5995 commented 1 year ago

Still more work to be done, but making progress. I was able to host a game. It published to the master server (only showed the ipv4 address of course), and was able to join the game. Shows here I was connected via ipv6, and the server was listening on ipv6 (I think):

image

image

andy5995 commented 1 year ago

Still more work to be done, but making progress. I was able to host a game. It published to the master server (only showed the ipv4 address of course), and was able to join the game. Shows here I was connected via ipv6, and the server was listening on ipv6 (I think):

What's more likely is something like this fellow mentioned

https://stackoverflow.com/a/7474120

The reason the address is already in use is because on many IPv6 networking stacks, by default an IPv6 socket will listen to both IPv4 and IPv6 at the same time. IPv4 connections will be handled transparently and mapped to a subset of the IPv6 space.