xentara-utils v1.0
Xentara utilities library
xentara::utils::network Namespace Reference

Networking functionality. More...

Classes

class  Address
 A network address, with Port number. More...
 
class  Backlog
 Marker for listening backlog. More...
 
class  BadAddressStringError
 An Exception that is thrown when a numeric address string had a bad format. More...
 
class  HostNotFoundError
 An Exception that is thrown when a host name lookup failed. More...
 
class  IllegalPortNumberError
 An Exception that is thrown when a port number is out of range. More...
 
class  MissingPortNumberError
 An Exception that is thrown when a host name/port number pair does not contain a port number. More...
 
struct  NonBlockingTag
 Type used to specify that a socket should be non blocking. More...
 
struct  RequirePortTag
 Type used to specify that a host name or address string must include a port number. More...
 
class  Socket
 A socket. More...
 

Concepts

concept  SockaddrCompatible
 A concept describing types that can be used as socket addresses.
 

Typedefs

using PortNumber = decltype(std::declval< sockaddr_in >().sin_port)
 The type for an IP port number. More...
 

Enumerations

enum class  DefaultPort : PortNumber
 Marker for host names/address strings with optional port number. More...
 
enum class  WithPort : PortNumber
 Marker used to specify a fixed port for host names/address strings. More...
 
enum class  AddressFamily : int
 Marker for address families. More...
 
enum class  SocketType : int
 Marker for socket types. More...
 
enum class  Protocol : int
 Marker for protocols. More...
 

Functions

auto initWindowsSockets () -> void
 Initializes the Windows socket subsystem (WinSock) More...
 

Variables

constexpr RequirePortTag kRequirePort
 A marker for host names/address strings with port number. More...
 
constexpr NonBlockingTag kNonBlocking
 A marker for creating non-blocking sockets. More...
 

Detailed Description

Networking functionality.

This namespace contains networking functionality.

Typedef Documentation

◆ PortNumber

using xentara::utils::network::PortNumber = typedef decltype(std::declval<sockaddr_in>().sin_port)

The type for an IP port number.

Enumeration Type Documentation

◆ AddressFamily

enum class xentara::utils::network::AddressFamily : int
strong

Marker for address families.

This marker is used to specify an address family in the style of AF_INET, AF_INET6, AF_UNSPEC etc.

Just cast the appropriate define to AddressFamily:

AddressFamily(AF_INET)
AddressFamily(AF_INET6)
AddressFamily(AF_UNSPEC)
AddressFamily
Marker for address families.
Definition: Options.hpp:80

◆ DefaultPort

Marker for host names/address strings with optional port number.

This marker is used to specify that a host name or address string may include a port number, and specifies the default port number to use if none is specified.

Just cast the default port number to DefaultPort:

DefaultPort
Marker for host names/address strings with optional port number.
Definition: Options.hpp:52

◆ Protocol

enum class xentara::utils::network::Protocol : int
strong

Marker for protocols.

This marker is used to specify an network protocol in the style of IPPROTO_TCP and IPPROTO_UDP.

Just cast the appropriate define to Protocol:

Protocol(IPPROTO_TCP)
Protocol(IPPROTO_UDP)
Protocol
Marker for protocols.
Definition: Options.hpp:108

◆ SocketType

enum class xentara::utils::network::SocketType : int
strong

Marker for socket types.

This marker is used to specify a socket type in the style of SOCK_STREAM or `SOCK_DGRAM.

Just cast the appropriate define to `SocketType:

SocketType(SOCK_STREAM)
SocketType(SOCK_DGRAM)
SocketType
Marker for socket types.
Definition: Options.hpp:94

◆ WithPort

Marker used to specify a fixed port for host names/address strings.

This marker is used to specify that a host name or address string may not include a port number, but a fixed port should be used.

Just cast the default port number to WithPort:

WithPort(8080)
WithPort
Marker used to specify a fixed port for host names/address strings.
Definition: Options.hpp:65

Function Documentation

◆ initWindowsSockets()

auto xentara::utils::network::initWindowsSockets ( ) -> void

Initializes the Windows socket subsystem (WinSock)

You can call this function if you which to use Windows socket functions without using any classes from the xentara::utils::network namespace. You do not have to call this function if you have already created any addresses or sockets using xentara::utils::network::Address or xentara::utils::network::Socket, as these initialize WinSock automatically.

This function is a noop under all operating systems except Windows.

Variable Documentation

◆ kNonBlocking

constexpr NonBlockingTag xentara::utils::network::kNonBlocking
constexpr

A marker for creating non-blocking sockets.

This marker is used to specify that a host name or address string must include a port number

◆ kRequirePort

constexpr RequirePortTag xentara::utils::network::kRequirePort
constexpr

A marker for host names/address strings with port number.

This marker is used to specify that a host name or address string must include a port number