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

An object which identifies an endpoint for Internet communication as a combination of an address and a port number. More...

#include "coral/net.hpp"

Public Member Functions

 Endpoint () CORAL_NOEXCEPT
 Constructs an Endpoint with address "*" and port zero.
 
 Endpoint (const ip::Address &address, const ip::Port &port) CORAL_NOEXCEPT
 Constructs an Endpoint from an Address and a Port.
 
 Endpoint (const std::string &specification)
 Constructs an Endpoint from a string on the form "address:port", where the ":port" part is optional and defaults to port zero. More...
 
 Endpoint (const sockaddr_in &sin)
 Constructs an Endpoint from a sockaddr_in object.
 
 Endpoint (const sockaddr &sa)
 Constructs an Endpoint from a sockaddr object. More...
 
const ip::AddressAddress () const CORAL_NOEXCEPT
 Returns the address.
 
void SetAddress (const ip::Address &value) CORAL_NOEXCEPT
 Sets the address.
 
const ip::PortPort () const CORAL_NOEXCEPT
 Returns the port.
 
void SetPort_ (const ip::Port &value) CORAL_NOEXCEPT
 Sets the port. More...
 
std::string ToString () const CORAL_NOEXCEPT
 Returns a string on the form "address:port".
 
coral::net::Endpoint ToEndpoint (const std::string &transport) const
 Returns a coral::net::Endpoint object which refers to the same endpoint. More...
 
sockaddr_in ToSockaddrIn () const
 Returns the endpoint address as a sockaddr_in object. More...
 

Detailed Description

An object which identifies an endpoint for Internet communication as a combination of an address and a port number.

Constructor & Destructor Documentation

coral::net::ip::Endpoint::Endpoint ( const std::string specification)
explicit

Constructs an Endpoint from a string on the form "address:port", where the ":port" part is optional and defaults to port zero.

Exceptions
std::out_of_rangeIf the number is out of the valid port range.
std::invalid_argumentIf the specification is otherwise invalid.
coral::net::ip::Endpoint::Endpoint ( const sockaddr &  sa)
explicit

Constructs an Endpoint from a sockaddr object.

Exceptions
std::invalid_argumentIf the address family of sa is not AF_INET.

Member Function Documentation

void coral::net::ip::Endpoint::SetPort_ ( const ip::Port value)

Sets the port.

Note
The underscore in the name of this function is due to a name collision with a macro in the Windows system headers.
coral::net::Endpoint coral::net::ip::Endpoint::ToEndpoint ( const std::string transport) const

Returns a coral::net::Endpoint object which refers to the same endpoint.

The transport must be specified. Currently, the only supported transport is "tcp".

Exceptions
std::invalid_argumentIf transport is empty.
sockaddr_in coral::net::ip::Endpoint::ToSockaddrIn ( ) const

Returns the endpoint address as a sockaddr_in object.

Exceptions
std::logic_errorIf the address is not an IPv4 address or the port is not a normal port number.

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