coral
A C++ library for distributed co-simulation
Public Member Functions | Static Public Member Functions | List of all members
coral::net::ip::Port Class Reference

An object which represents an internet port number. More...

#include "coral/net.hpp"

Public Member Functions

 Port (std::uint16_t port=0u) CORAL_NOEXCEPT
 Constructor which takes a port number.
 
 Port (const std::string &port)
 Constructor which takes a port number in string form, or the special value "*". More...
 
bool IsNumber () const CORAL_NOEXCEPT
 Returns whether this is a normal port number in the range 0-65535.
 
bool IsAnyPort () const CORAL_NOEXCEPT
 Returns whether the object was initialised with the special value "*".
 
std::uint16_t ToNumber () const
 Returns the port number. More...
 
std::string ToString () const CORAL_NOEXCEPT
 Returns a string representation of the port number.
 
std::uint16_t ToNetworkByteOrder () const
 Returns the port number in network byte order. More...
 

Static Public Member Functions

static Port FromNetworkByteOrder (std::uint16_t nPort) CORAL_NOEXCEPT
 Constructs a Port from a port number in network byte order.
 

Detailed Description

An object which represents an internet port number.

This object may contain a port number in the range 0 through 65535, or it may, depending on the context in which it is used, contain the special value "*", which means "any port" or "OS-assigned (ephemeral) port".

Constructor & Destructor Documentation

coral::net::ip::Port::Port ( const std::string port)

Constructor which takes a port number in string form, or the special value "*".

Exceptions
std::invalid_argumentIf the string does not contain a number.
std::out_of_rangeIf the number is out of the valid port range.

Member Function Documentation

std::uint16_t coral::net::ip::Port::ToNetworkByteOrder ( ) const

Returns the port number in network byte order.

Precondition
IsNumber() must return true.
std::uint16_t coral::net::ip::Port::ToNumber ( ) const

Returns the port number.

Precondition
IsNumber() must return true.

The documentation for this class was generated from the following file: