Commit Graph

50 Commits (38c97e14926f4bc538c20b24f8a3decdef1668f9)

Author SHA1 Message Date
Patric Stout 1b75a29d12 Fix: destroying a TCPConnecter that was still resolving made illegal writes
Basically, we should join the resolve thread before we destruct
the object.
3 years ago
Patric Stout 664a8c3e85 Codechange: move connection_string to private for TCPConnecter
The most common case never needs access to it anymore. Make the
one exception to this explicit. This means the fact that we
store it is now an implementation detail.
3 years ago
Patric Stout f187708b3b
Fix f7e390bd: getpeername() doesn't work on closed sockets (#9213) 3 years ago
Patric Stout f7e390bdc0
Feature: use Happy Eyeballs to make network connections (TCP-only) (#9199)
Hostnames like "content.openttd.org" resolve into multiple IPv4 and IPv6.
It is possible that either of the IPs is not working, either due to
a poorly configured OS (having IPv6 but no valid route), broken network
paths, or a service that is temporary unavailable.

Instead of trying the IPs one by one, waiting for a 3s timeout between
each, be a bit more like browsers, and stack attempts on top of each
other with slight delays. This is called Happy Eyebells.

Initially, try the first IPv6 address. If within 250ms there is no
connection yet, try the first IPv4 address. 250ms later, try the
second IPv6 address, etc, till all addresses are tried.

If any connection is created, abort all the other (pending) connections
and use the one that is created. If all fail 3s after the last connect(),
trigger a timeout for all.
3 years ago
Patric Stout f94fb93779
Codechange: use connection_string in favour of NetworkAddress (#9197)
We now resolve the connection_string to a NetworkAddress in a much
later state. This means there are fewer places constructing a NetworkAddress.

The main benefit of this is in later PRs that introduce different types
of NetworkAddresses. Storing this in things like NetworkGameList is
rather complex, especially as NetworkAddress has to be mutable at all
times.

Additionally, the NetworkAddress is a complex object to store simple
information: how to connect to this server.
3 years ago
Jonathan G Rennison b0f192abc4 Fix: Racy use of flags in TCPConnecter::CheckCallbacks
conected and aborted flags are used concurrently from multiple threads.
4 years ago
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 5 years ago
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 5 years ago
Michael Lutz 05bc2ed7cb Codechange: Replace custom thread code with C++11 thread objects.
We assume a conforming C++11 compiler environment that has a valid <thread>-header.
Failure to run a real thread is handled gracefully.
5 years ago
peter1138 07de9d6c3f Codechange: Use override keyword in networking classes. 5 years ago
Patric Stout e3c639a09f Remove: ENABLE_NETWORK switch
This switch has been a pain for years. Often disabling broke
compilation, as no developer compiles OpenTTD without, neither do
any of our official binaries.

Additionaly, it has grown so hugely in our codebase, that it
clearly shows that the current solution was a poor one. 350+
instances of "#ifdef ENABLE_NETWORK" were in the code, of which
only ~30 in the networking code itself. The rest were all around
the code to do the right thing, from GUI to NewGRF.

A more proper solution would be to stub all the functions, and
make sure the rest of the code can simply assume network is
available. This was also partially done, and most variables were
correct if networking was disabled. Despite that, often the #ifdefs
were still used.

With the recent removal of DOS, there is also no platform anymore
which we support where networking isn't working out-of-the-box.

All in all, it is time to remove the ENABLE_NETWORK switch. No
replacement is planned, but if you feel we really need this option,
we welcome any Pull Request which implements this in a way that
doesn't crawl through the code like this diff shows we used to.
5 years ago
planetmaker c24374f99c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow) 12 years ago
rubidium 6247bdbdb4 (svn r24642) -Codechange: add helper function to see if there is anything in the send queue 12 years ago
rubidium adfd648031 (svn r22068) -Codechange/Fix: return "connection lost" instead of "okay" when SendPackets closed the connection 14 years ago
rubidium eb299736c1 (svn r21886) -Codechange: move documentation towards the code to make it more likely to be updated [n]. 14 years ago
rubidium 216e48cd07 (svn r21399) -Change/Feature/Fix [FS#4284]: perform the compression of savegames to send to the client asynchroniously. This will reduce the lag of the other clients to the time it takes to make the memory dump and it will speed up downloading the map as the download starts earlier (possibly with a slightly lower bandwidth due to slow compression). This should also fix the lag message people get when the savegame compression takes more than a few seconds. 14 years ago
rubidium fd752ca2b0 (svn r21363) -Add: support for limiting the amount of (accepted) incoming data 14 years ago
rubidium b6c2216749 (svn r21358) -Codechange: make some network function names conform to coding style 14 years ago
rubidium f555e6d72e (svn r20933) -Codechange: move some more client related methods and such to network_client.cpp 14 years ago
rubidium 82fc28f77f (svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, if a header require a header make it include that header 15 years ago
rubidium f89d6bea0e (svn r18801) -Fix: in some cases error messages weren't properly sent to the client before closing the connection. As a result the client would say 'connection lost' when the cause was something completely different. 15 years ago
rubidium df75db67eb (svn r17742) -Codechange: remove unused variable from Recv_Packet 15 years ago
rubidium 5ff6053326 (svn r17699) -Codechange: move #ifdef ENABLE_NETWORK till after the 'generic' includes so compilation without network support doesn't get broken as easily by changes in header files 15 years ago
rubidium 7fbc33dae1 (svn r17248) -Fix: add GPL license notice where appropriate 15 years ago
rubidium 9b156c1bd4 (svn r16601) -Fix [FS#2880]: try 2... hopefully better this time 15 years ago
rubidium 2a6e9288fd (svn r15971) -Codechange: make it possible for UDP socket handlers to bind to multiple sockets. 15 years ago
rubidium 4f5a8b15ed (svn r15206) -Fix [FS#2567]: memory corruption due to not properly cleanup up the mess when cancelling a download 16 years ago
rubidium 28a641066e (svn r15163) -Change/Fix: use a non-blocking method to resolve the hostname and connect to game servers. 16 years ago
rubidium e18c24cdb5 (svn r15079) -Codechange: split tcp 'backend' and in-game handling like it is for UDP. 16 years ago
rubidium 427e2d30c5 (svn r14915) -Codechange: unify the receiving and sending of commands, and thus unifying most of the validity checking too. 16 years ago
rubidium e198bf02ab (svn r14766) -Fix (r14730ish): remove unused typedef. 16 years ago
rubidium e626e07bd3 (svn r14759) -Fix (r14730): tab completion causing out-of-bounds read. 16 years ago
rubidium afddfcb2b1 (svn r14730) -Codechange: remove the need for networkclientsockets and networkclientinfo structs to be in a contiguous piece of memory and put them in a pool.
-Note: 255 should really be enough for now... making it any more means network protocol bumps.
16 years ago
rubidium 52fb6b7d7c (svn r14724) -Codechange: move some NetworkClientSocket related function/definitions closer together. 16 years ago
rubidium 9476a49763 (svn r14723) -Codechange: shuffling some stuff around to reduce indirect #include dependencies. 16 years ago
rubidium ae96ca635c (svn r14721) -Codechange: s/NetworkTCPSocketHandler/NetworkClientSocket/ as it's (way) more descriptive what it's used for. 16 years ago
rubidium b4734ee9a4 (svn r14719) -Codechange: replace DEREF_CLIENT with an instance function and replace looping socket structs with info structs when the loop is only interested in the info structs (i.e. not derefing the info from sockets when one can loop info directly and the socket isn't used) 16 years ago
rubidium 782b80eff7 (svn r14709) -Codechange: make a clearer distinction between 'unique' client identification ids and the indices into the clients/client info arrays. 16 years ago
rubidium 3b798599b6 (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with. 16 years ago
rubidium ac528411df (svn r11818) -Codechange: split player.h into smaller pieces. 17 years ago
rubidium 872e74c028 (svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients when a command failed instead of only the client that actually did the command. 17 years ago
rubidium 24c4d5b06d (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {}; 18 years ago
rubidium a2b5b74b83 (svn r9038) -Fix [FS#115]: inactive connections are not automatically kicked, i.e. people who only open a telnet (or similar) connection to a server. 18 years ago
celestar 0ed4b64e64 (svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives). 18 years ago
rubidium 59f4f056df (svn r8525) -Codechange: make NetworkSend_Packet(s) and NetworkRecv_Packet functions of NetworkTCPSocketHandler. 18 years ago
rubidium 86b046864a (svn r8461) -Feature: check for NewGRF compatability before actually downloading the map from a game server when connecting from the command prompt and internal console. 18 years ago
rubidium f72dde5236 (svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions. 18 years ago
rubidium f66b373b52 (svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState. 18 years ago
rubidium b2f85eb044 (svn r7834) -Codechange: cleanup the includes of network/core a little; include headers in headers when the header needs types/constants defined in them. 18 years ago
rubidium 66bbf336c6 (svn r7759) -Merge: makefile rewrite. This merge features:
- A proper ./configure, so everything needs to be configured only once, not for every make.
 - Usage of makedepend when available. This greatly reduces the time needed for generating the dependencies.
 - A generator for all project files. There is a single file with sources, which is used to generate Makefiles and the project files for MSVC.
 - Proper support for OSX universal binaries.
 - Object files for non-MSVC compiles are also placed in separate directories, making is faster to switch between debug and release compiles and it does not touch the directory with the source files.
 - Functionality to make a bundle of all needed files for for example a nightly or distribution of a binary with all needed GRFs and language files.

Note: as this merge moves almost all files, it is recommended to make a backup of your working copy before updating your working copy.
18 years ago