summaryrefslogtreecommitdiff
path: root/src/network/core/tcp.h
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-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-05-13Codechange: [Network] split CloseSocket and CloseConnection more clearly (#9261)Patric Stout
* Codechange: [Network] split CloseSocket and CloseConnection more clearly - CloseSocket now closes the actual OS socket. - CloseConnection frees up the resources to just before CloseSocket. - dtors call CloseSocket / CloseConnection where needed.
2021-05-13Fix #9255: [Network] TCPConnecter crashes when hostname not found (#9259)Patric Stout
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-08Codechange: move connection_string to private for TCPConnecterPatric Stout
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.
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-24Codechange: Use override keyword in networking classes.peter1138
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.
2013-01-08(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by ↵planetmaker
Eagle_rainbow)
2012-10-28(svn r24642) -Codechange: add helper function to see if there is anything in ↵rubidium
the send queue
2011-02-12(svn r22068) -Codechange/Fix: return "connection lost" instead of "okay" ↵rubidium
when SendPackets closed the connection
2011-01-22(svn r21886) -Codechange: move documentation towards the code to make it ↵rubidium
more likely to be updated [n].
2010-12-05(svn r21399) -Change/Feature/Fix [FS#4284]: perform the compression of ↵rubidium
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.
2010-11-30(svn r21363) -Add: support for limiting the amount of (accepted) incoming datarubidium
2010-11-30(svn r21358) -Codechange: make some network function names conform to coding ↵rubidium
style
2010-10-15(svn r20933) -Codechange: move some more client related methods and such to ↵rubidium
network_client.cpp
2010-01-15(svn r18809) -Codechange/Cleanup: remove unneeded headers from some files, ↵rubidium
if a header require a header make it include that header
2010-01-14(svn r18801) -Fix: in some cases error messages weren't properly sent to the ↵rubidium
client before closing the connection. As a result the client would say 'connection lost' when the cause was something completely different.
2009-10-07(svn r17742) -Codechange: remove unused variable from Recv_Packetrubidium
2009-10-04(svn r17699) -Codechange: move #ifdef ENABLE_NETWORK till after the ↵rubidium
'generic' includes so compilation without network support doesn't get broken as easily by changes in header files
2009-08-21(svn r17248) -Fix: add GPL license notice where appropriaterubidium
2009-06-19(svn r16601) -Fix [FS#2880]: try 2... hopefully better this timerubidium
2009-04-07(svn r15971) -Codechange: make it possible for UDP socket handlers to bind ↵rubidium
to multiple sockets.
2009-01-22(svn r15206) -Fix [FS#2567]: memory corruption due to not properly cleanup ↵rubidium
up the mess when cancelling a download
2009-01-20(svn r15163) -Change/Fix: use a non-blocking method to resolve the hostname ↵rubidium
and connect to game servers.
2009-01-14(svn r15079) -Codechange: split tcp 'backend' and in-game handling like it ↵rubidium
is for UDP.
2009-01-08(svn r14915) -Codechange: unify the receiving and sending of commands, and ↵rubidium
thus unifying most of the validity checking too.
2008-12-29(svn r14766) -Fix (r14730ish): remove unused typedef.rubidium
2008-12-28(svn r14759) -Fix (r14730): tab completion causing out-of-bounds read.rubidium
2008-12-23(svn r14730) -Codechange: remove the need for networkclientsockets and ↵rubidium
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.
2008-12-23(svn r14724) -Codechange: move some NetworkClientSocket related ↵rubidium
function/definitions closer together.
2008-12-23(svn r14723) -Codechange: shuffling some stuff around to reduce indirect ↵rubidium
#include dependencies.
2008-12-23(svn r14721) -Codechange: s/NetworkTCPSocketHandler/NetworkClientSocket/ as ↵rubidium
it's (way) more descriptive what it's used for.
2008-12-23(svn r14719) -Codechange: replace DEREF_CLIENT with an instance function and ↵rubidium
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)
2008-12-22(svn r14709) -Codechange: make a clearer distinction between 'unique' client ↵rubidium
identification ids and the indices into the clients/client info arrays.
2008-09-30(svn r14421) -Codechange: rename all player variables/types to company *or* ↵rubidium
client so it is immediatelly clear which one you are working with.
2008-01-12(svn r11818) -Codechange: split player.h into smaller pieces.rubidium
2007-07-10(svn r10501) -Fix [FS#1015]: error dialog was sometimes shown on all clients ↵rubidium
when a command failed instead of only the client that actually did the command.
2007-03-07(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};rubidium
2007-03-06(svn r9038) -Fix [FS#115]: inactive connections are not automatically ↵rubidium
kicked, i.e. people who only open a telnet (or similar) connection to a server.
2007-02-23(svn r8857) -Documentation: Added some doxygen @file tags, repaired others ↵celestar
(the @file tag MUST be found before any line of code, that includes preprocessor directives).