* Only clean up the IPv4 socket if we are able to enable IPv4 mapping of IPv6 addresses ''and'' are able to create an IPv6 socket
* Add some more debug messages to be able to see what sockets could be created
* Close sockets when they've become useless/invalid
This should fix#534 for real (unlike r7541, which fixed it and then reintroduced another bug causing the same symptom).
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7543 4a71c877-e1ca-e34f-864e-861f7616d084
* Allow failure for setting up of one of the sockets
- More accurately: require only one socket to succeed
* Try to use the IPv4 to IPv6 mapping feature if the host OS provides it
- This allows us to use only a single socket on those systems for both listening to IPv4 and IPv6
This should fix#534.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7541 4a71c877-e1ca-e34f-864e-861f7616d084
* Add a new field: secondaryHosts, an array of two fallback hosts
- Canibalize the entire "misc" field and part of the "extra" field for this
- When connecting, first try the primary "host" field, then fall back to the hosts in secondaryHosts (in order)
* Add a new field: gameId, used on the lobby server to link multiple lobby connections to a single game entry
- First (attempt to) connect to the lobby with all available address families (currently IPv4 and IPv6)
- Then ask for a gameId from the lobby server using the first established lobby connection
- Set the gameId field in the GAMESTRUCT to the one retrieved
- Transmit the GAMESTRUCT using a "addg" command to the lobby over each lobby connection
- The lobby then compares all incoming ID numbers with ID numbers already present
- If there's a match it will use the GAMESTRUCT already present and only add a new hostname to the list
This is the last change, part of, and closes#452
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7364 4a71c877-e1ca-e34f-864e-861f7616d084
* Make the "addg" command return a status code (ranging 200-299 on success) and message (MOTD on succes)
* Don't use the "motd" command anymore to check the lobby status, instead use the returned status code for that purpose.
* Allow MOTD strings of arbitrary length (by sending along the length)
This modification ensures that ''proper'' connectivity checking is being performed on the game server (and reported to the user accurately).
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7323 4a71c877-e1ca-e34f-864e-861f7616d084
* Duplicate the entire ASSERT() call instead of conditionally expanding its parameter
- Depending on whether we are or are not compiling on Windows
Thanks go to Buginator for reporting this.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7306 4a71c877-e1ca-e34f-864e-861f7616d084
This way it is no longer required to first explicitly check whether
connections are pending (through checkSockets, which select(2)s) and
only then accept(2) it. Now you can attempt to accept the connection,
and if one is available it'll get returned, NULL otherwise.
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7300 4a71c877-e1ca-e34f-864e-861f7616d084
* Rename read_all to readNoInt because that function is a read(2) variant that doesn't get interrupted by signals (EINTR)
* Add Doxygen comments to readNoInt and writeAll
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7298 4a71c877-e1ca-e34f-864e-861f7616d084
* Use the "SOCKET" typedef to represent socket descriptors (instead of "int")
* Add wrapper functions for getting & setting the last socket error ("errno" on Unix)
* Add a wrapper function for strerror, strsockerror, that works on Windows
* Use recv(2) and send(2) instead of read(2) and write(2) respectively
* Use INVALID_SOCKET and SOCKET_ERROR instead of -1 to find errors
* Move setting of sockets to blocking/non-blocking to a separate function
* Add Windows-specific wrapper functions for getaddrinfo() and freeaddrinfo()
- Currently work only from 2000 *or* XP upwards, documentation is fuzzy.
Addresses #435
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7289 4a71c877-e1ca-e34f-864e-861f7616d084
* Check for write_all() == -1 (error) instead of "< 0" and "!= size" to
see whether sending has failed.
* Don't just mark sockets as "invalid" on error (by setting them to
NULL), close them as well.
* Give decent error messages on write failure (most likely a disconnect)
Addresses #435
git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@7288 4a71c877-e1ca-e34f-864e-861f7616d084