summaryrefslogtreecommitdiff
path: root/src/network/core/tcp_connect.cpp
AgeCommit message (Collapse)Author
2021-07-16Feature: allow the use of STUN to connect client and server togetherPatric Stout
This method doesn't require port-forwarding to be used, and works for most common NAT routers in home setups. But, for sure it doesn't work for all setups, and not everyone will be able to use this.
2021-07-16Codechange: allow Connect() to bind to a local addressPatric Stout
2021-07-11Feature: join servers based on their invite codePatric Stout
This removes the need to know a server IP to join it. Invite codes are small (~7 characters) indentifiers for servers, which can be exchanged with other players to join the servers.
2021-07-11Change: groundwork to allow ServerAddress to use invite codesPatric Stout
Normally TCPConnecter will do a DNS resolving of the connection_string and connect to it. But for SERVER_ADDRESS_INVITE_CODE this is different: the Game Coordinator does the "resolving". This means we need to allow TCPConnecter to not setup a connection and allow it to be told when a connection has been setup by an external (to TCPConnecter) part of the code. We do this by telling the (active) socket for the connection. This means the rest of the code doesn't need to know the TCPConnecter is not doing a simple resolve+connect. The rest of the code only cares the connection is established; not how it was established.
2021-07-11Codechange: track servers with a ServerAddress instead of a NetworkAddressPatric Stout
This allows future extensions to have different ways of referencing a server, instead of forcing to use IP:port.
2021-06-29Fix f7e390bd: freeaddrinfo() is not guaranteed to handle a nullptr graceful ↵Patric Stout
(#9404)
2021-06-17Cleanup: use nullptr instead of 0 or NULLRubidium
2021-06-15Codechange: [Network] Make hostname/client IP return strings instead of a ↵rubidium42
C-string
2021-06-13Codechange: convert printf DEBUG statements to fmt Debug statementsrubidium42
2021-05-13Fix #9255: [Network] TCPConnecter crashes when hostname not found (#9259)Patric Stout
2021-05-12Change: reworked the debug levels for network facility (#9251)Patric Stout
It now follows very simple rules: 0 - Fatal, user should know about this 1 - Error, but we are recovering 2 - Warning, wrong but okay if you don't know 3 - Info, information you might care about 4 - 5 - Debug #1 - High level debug messages 6 - Debug #2 - Low level debug messages 7 - Trace information
2021-05-10Change: reworded many of the network errors during connect/listen (#9230)Patric Stout
Also changed some levels to 0, as a failing listen() is something we should tell the user about. Hiding this information is a bit evil.
2021-05-08Fix: destroying a TCPConnecter that was still resolving made illegal writesPatric Stout
Basically, we should join the resolve thread before we destruct the object.
2021-05-08Fix f7e390bd: getpeername() doesn't work on closed sockets (#9213)Patric Stout
2021-05-06Feature: use Happy Eyeballs to make network connections (TCP-only) (#9199)Patric Stout
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.
2021-05-05Codechange: use connection_string in favour of NetworkAddress (#9197)Patric Stout
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.
2020-06-18Fix: Racy use of flags in TCPConnecter::CheckCallbacksJonathan G Rennison
conected and aborted flags are used concurrently from multiple threads.
2019-11-10Cleanup: Removed SVN headersS. D. Cloudt
2019-04-10Codechange: Use null pointer literal instead of the NULL macroHenry Wilson
2019-04-06Codechange: Replace custom thread code with C++11 thread objects.Michael Lutz
We assume a conforming C++11 compiler environment that has a valid <thread>-header. Failure to run a real thread is handled gracefully.
2019-03-26Codechange: Removed SmallVector completelyHenry Wilson
2019-03-26Codechange: Replaced SmallVector::[Begin|End]() with std alternativesHenry Wilson
2019-03-26Codechange: Replaced SmallVector::Append() with ↵Henry Wilson
std::vector::[push|emplace]_back()
2019-03-26Codechange: Replaced SmallVector::Erase() with std::vector::erase()Henry Wilson
2019-03-20Remove: ENABLE_NETWORK switchPatric Stout
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.
2016-10-30(svn r27670) -Add: [FS#6471] Assign descriptive names to (GNU pthread) ↵frosch
threads. (JGR)
2014-04-23(svn r26482) -Codechange: add an include that allows us to undefine/redefine ↵rubidium
"unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values
2011-01-22(svn r21886) -Codechange: move documentation towards the code to make it ↵rubidium
more likely to be updated [n].
2009-10-04(svn r17693) -Cleanup: remove some unneeded includesrubidium
2009-09-01(svn r17339) -Codechange: move thread related files to their own directory ↵rubidium
(like done for video, music, sound, etc)
2009-08-21(svn r17248) -Fix: add GPL license notice where appropriaterubidium
2009-04-02(svn r15920) -Codechange: make the (TCP) connecting less AF dependent.rubidium
2009-04-02(svn r15917) -Codechange: remove the latest traces of NetworkAddress::GetIP.rubidium
2009-01-20(svn r15163) -Change/Fix: use a non-blocking method to resolve the hostname ↵rubidium
and connect to game servers.