OpenTTD Source: src/network/core/os_abstraction.cpp File Reference

OpenTTD Source 15.0-beta1

Functions
os_abstraction.cpp File Reference

OS specific implementations of functions of the OS abstraction layer for network stuff. More...

`#include "stdafx.h"`
`#include "os_abstraction.h"`
`#include "../../string_func.h"`
`#include "../../3rdparty/fmt/format.h"`
`#include <mutex>`
`#include "../../safeguards.h"`

Go to the source code of this file.

## Functions
bool | SetNonBlocking (SOCKET d)
| Try to set the socket into non-blocking mode.
bool | SetNoDelay (SOCKET d)
| Try to set the socket to not delay sending.
bool | SetReusePort (SOCKET d)
| Try to set the socket to reuse ports.
NetworkError | GetSocketError (SOCKET d)
| Get the error from a socket, if any.

## Detailed Description

OS specific implementations of functions of the OS abstraction layer for network stuff.

The general idea is to have simple abstracting functions for things that require different implementations for different environments. In here the functions, and their documentation, are defined only once and the implementation contains the #ifdefs to change the implementation. Since Windows is usually different that is usually the first case, after that the behaviour is usually Unix/BSD-like with occasional variation.

Definition in file os_abstraction.cpp.

## Function Documentation

## ◆ GetSocketError()

NetworkError GetSocketError | ( | SOCKET | d | ) |

Get the error from a socket, if any.

Parameters

  d | The socket to get the error from.

Returns
  The errno on the socket.

Definition at line 184 of file os_abstraction.cpp.

Referenced by TCPConnecter::CheckActivity().

## ◆ SetNoDelay()

bool SetNoDelay | ( | SOCKET | d | ) |

Try to set the socket to not delay sending.

Parameters

  d | The socket to disable the delaying for.

Returns
  True if disabling the delaying succeeded, otherwise false.

Definition at line 151 of file os_abstraction.cpp.

Referenced by TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::AcceptClient(), TCPConnecter::Connect(), and ListenLoopProc().

## ◆ SetNonBlocking()

bool SetNonBlocking | ( | SOCKET | d | ) |

Try to set the socket into non-blocking mode.

Parameters

  d | The socket to set the non-blocking more for.

Returns
  True if setting the non-blocking mode succeeded, otherwise false.

Definition at line 133 of file os_abstraction.cpp.

Referenced by TCPListenHandler< Tsocket, Tfull_packet, Tban_packet >::AcceptClient(), TCPConnecter::Connect(), ListenLoopProc(), and NetworkUDPSocketHandler::ReceivePackets().

## ◆ SetReusePort()

bool SetReusePort | ( | SOCKET | d | ) |

Try to set the socket to reuse ports.

Parameters

  d | The socket to reuse ports on.

Returns
  True if disabling the delaying succeeded, otherwise false.

Definition at line 167 of file os_abstraction.cpp.

Referenced by TCPConnecter::Connect(), and ListenLoopProc().