Commit Graph

56 Commits (8fa53f543a5929bdbb12c8776ae9577594f9eba7)

Author SHA1 Message Date
Patric Stout 8fa53f543a
Change: [Network] lower TCP connect() timeout to 3s (#9112)
Currently we use default OS timeout for TCP connections, which
is around 30s. 99% of the users will never notice this, but there
are a few cases where this is an issue:

- If you have a broken IPv6 connection, using Content Service is
  first tried over IPv6. Only after 30s it times out and tries
  IPv4. Nobody is waiting for that 30s.
- Upcoming STUN support has several methods of establishing a
  connection between client and server. This requires feedback
  from connect() to know if any method worked (they have to be
  tried one by one). With 30s, this would take a very long time.

What is good to mention, is that there is no good value here. Any
value will have edge-cases where the experience is suboptimal. But
with 3s we support most of the stable connections, and if it fails,
the user can just retry. On the other side of the spectrum, with 30s,
it means the user has no possibility to use the service. So worst case
we annoy a few users with them having the retry vs annoying a few
users which have no means of resolving the situation.
3 years ago
rubidium42 65c5a64719 Fix: [Network] errno and strerror do not handle network errors on Windows 3 years ago
Rubidium d2fe8c2842 Change: warn the user about the resolving of an address being extra very slow 3 years ago
Niels Martin Hansen e0561dbded Fix #8713: Change OTTD2FS and FS2OTTD to return string objects instead of static buffers 3 years ago
Patric Stout 8fbf5bef60 Fix: workarounds for two emscripten bugs in the network stack 4 years ago
Patric Stout d15dc9f40f Add: support for emscripten (play-OpenTTD-in-the-browser)
Emscripten compiles to WASM, which can be loaded via
HTML / JavaScript. This allows you to play OpenTTD inside a
browser.

Co-authored-by: milek7 <me@milek7.pl>
4 years ago
Jonathan G Rennison 1ac0d4a5b2 Fix: Thread unsafe use of NetworkAddress::GetAddressAsString
Remove static buffer form of NetworkAddress::GetAddressAsString.
This is used in multiple threads concurrently, and is not thread-safe.

Replace it with a form returning std::string.
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 e804173595 Codechange: If something is a vector of strings, use a vector of strings instead of an AutoFreeSmallVector. 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
frosch 396dde1636 (svn r27092) -Fix/Add [FS#6186]: Compilation on OS/2 (smedles) 10 years ago
rubidium 0463dbdc9e (svn r26482) -Codechange: add an include that allows us to undefine/redefine "unsafe" functions to prevent them from being used, and thus having to care about certain aspects of their return values 10 years ago
planetmaker c24374f99c (svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow) 12 years ago
rubidium bd64bf6372 (svn r23193) -Codechange: don't cast away const unneededly 13 years ago
rubidium 289133be14 (svn r22695) -Fix [FS#4697]: mark addresses that could not be resolved as 'do not resolve anymore' as well, instead of trying to resolve them each and every time the address is accessed 13 years ago
rubidium eb299736c1 (svn r21886) -Codechange: move documentation towards the code to make it more likely to be updated [n]. 14 years ago
frosch 98250ad8da (svn r20951) -Codechange: Add SmallMap::Contains() and use it. 14 years ago
rubidium 6b35de215c (svn r19385) -Fix [FS#3684]: [IPv6] Netmask calculations were wrong if cidr >= 32. 14 years ago
rubidium d6cded5380 (svn r17693) -Cleanup: remove some unneeded includes 15 years ago
rubidium 7fbc33dae1 (svn r17248) -Fix: add GPL license notice where appropriate 15 years ago
smatz d4971a22d0 (svn r16265) -Fix (r16238): wrong format string for debug output 15 years ago
rubidium 951b9e7615 (svn r16238) -Change: improve/clarify some network related debug "error" messages by adding more information to them. Also give some clues on how to fix certain issues (like failing advertising). 15 years ago
rubidium 47e2901e18 (svn r16034) -Fix: compile warnings generated by 64 bits MSVC. 15 years ago
rubidium 460fbc7c92 (svn r16007) -Fix (r16004): when we want to bind to both IPv4 and IPv6, make the master socket do that too; too bad getaddrinfo can't handle binding to any address on any port at the same time :( 15 years ago
rubidium 28bce241fd (svn r16005) -Fix: assertion when there is no last joined server; when you've got an unresolved address, the hostname cannot be resolved either so return it as-is. 15 years ago
rubidium 8477e92386 (svn r16004) -Fix (r16000): explicitly binding to an IPv4 socket would try to register an IPv6 address (only if it could ofcourse) 15 years ago
rubidium 0f0cc67d62 (svn r15990) -Codechange: provide a thread safe variant of GetAddressAsString. 15 years ago
rubidium 080095ade5 (svn r15984) -Codechange: prepare the UDP receiver to process multiple types of returned server lists. 15 years ago
rubidium cd8da0d69e (svn r15982) -Codechange: use GetAddressAsString to get the name instead of passing the hostname and the IP into a string. 15 years ago
rubidium 9d6edae94d (svn r15981) -Fix: don't print the address family when writing the IP+port to the config file. 15 years ago
rubidium 18146572b0 (svn r15980) -Codechange: don't try to bind to the same socket twice; it's quite pointless. 15 years ago
rubidium c2152fa31f (svn r15979) -Codechange: tweak the debug/warning levels of some of the messages when binding 15 years ago
rubidium 20e82c46d3 (svn r15976) -Codechange: make it a bit more clear for what (type of) address binding fails 15 years ago
rubidium 1eb4aa971e (svn r15975) -Codechange: register each of the IPs we have bound to to the masterserver 15 years ago
rubidium c0f8214218 (svn r15972) -Codechange: remove unneeded parameter 15 years ago
rubidium 6db7f15b3a (svn r15970) -Codechange: make it possible to resolve a single address into multiple sockets. 15 years ago
rubidium fdddfd6269 (svn r15968) -Codechange: do not allocate a buffer for NetworkAddresses so passing it around is easier. 15 years ago
rubidium 616cac0c54 (svn r15951) -Fix (r15946) [FS#2803]: ofcourse a couple of OSes/compilers do not provide a nice 'interface', so we have to do it the ugly way. 15 years ago
glx 5eed35ef54 (svn r15950) -Fix (r15946): mingw compilation 15 years ago
rubidium 2fd9f0fffa (svn r15946) -Codechange: move netmask matching to NetworkAddress and add some support for IPv6 netmask matching. 15 years ago
rubidium 7cf4639255 (svn r15944) -Codechange: disable IPv4 over IPv6 sockets as there is no default value and not all OSes actually support IPv4 over IPv6 so making it the same on all OSes eases debugging and such 15 years ago
rubidium ce06df313d (svn r15941) -Codechange: jonty-comp's wish partly implemented (content server) ;) 15 years ago
rubidium 1463b00b48 (svn r15940) -Codechange: move setting reuse address to the binding process. 15 years ago
rubidium 2bfc9ca50c (svn r15934) -Fix: work around Solaris' inability to "parse" 0 as defined in the specifications. 15 years ago
glx 65d10e66f0 (svn r15933) -Fix (r15920): mingw doesn't know getaddrinfo() and freeaddrinfo() either 15 years ago
rubidium 47602d7b60 (svn r15925) -Codechange: remove _network_server_bind_ip as it's pretty AF dependant. 15 years ago
rubidium dccfba6e20 (svn r15924) -Codechange: replace NetworkResolveHost with something less AF dependant. 15 years ago
rubidium 632d74c6b1 (svn r15922) -Codechange: unify the ways to listen on a socket 15 years ago
rubidium ba5aafb9bb (svn r15921) -Fix: some OSes don't like sizeof(sockaddr_storage) but want sizeof(sockaddr) or whatever is 'valid' for the given protocol 15 years ago