| Home | Libraries | People | FAQ | More

# boost::asio::ip::basic_endpoint< Protocol > Class Template Reference

List of all members.

## Detailed Description

### template<typename Protocol>
class boost::asio::ip::basic_endpoint< Protocol >

Describes an endpoint for a version-independent IP socket.

The boost::asio::ip::basic_endpoint class template describes an endpoint that may be associated with a particular socket.

Thread Safety:
  Distinct objects: Safe.
  Shared objects: Unsafe.

Concepts:
  Endpoint.

## Public Types

typedef Protocol | protocol_type
| The protocol type associated with the endpoint.
typedef implementation_defined | data_type
| The type of the endpoint structure. This type is dependent on the underlying implementation of the socket layer.
typedef implementation_defined | size_type
| The type for the size of the endpoint structure. This type is dependent on the underlying implementation of the socket layer.

## Public Member Functions

| basic_endpoint ()
| Default constructor.
| basic_endpoint (const Protocol &protocol, unsigned short port_num)
| Construct an endpoint using a port number, specified in the host's byte order. The IP address will be the any address (i.e. INADDR_ANY or in6addr_any). This constructor would typically be used for accepting new connections.
| basic_endpoint (const boost::asio::ip::address &addr, unsigned short port_num)
| Construct an endpoint using a port number and an IP address. This constructor may be used for accepting connections on a specific interface or for making a connection to a remote endpoint.
| basic_endpoint (const basic_endpoint &other)
| Copy constructor.
basic_endpoint & | operator= (const basic_endpoint &other)
| Assign from another endpoint.
protocol_type | protocol () const
| The protocol associated with the endpoint.
data_type * | data ()
| Get the underlying endpoint in the native type.
const data_type * | data () const
| Get the underlying endpoint in the native type.
size_type | size () const
| Get the underlying size of the endpoint in the native type.
void | resize (size_type size)
| Set the underlying size of the endpoint in the native type.
size_type | capacity () const
| Get the capacity of the endpoint in the native type.
unsigned short | port () const
| Get the port associated with the endpoint. The port number is always in the host's byte order.
void | port (unsigned short port_num)
| Set the port associated with the endpoint. The port number is always in the host's byte order.
boost::asio::ip::address | address () const
| Get the IP address associated with the endpoint.
void | address (const boost::asio::ip::address &addr)
| Set the IP address associated with the endpoint.

## Friends

bool | operator== (const basic_endpoint< Protocol > &e1, const basic_endpoint< Protocol > &e2)
| Compare two endpoints for equality.
bool | operator!= (const basic_endpoint< Protocol > &e1, const basic_endpoint< Protocol > &e2)
| Compare two endpoints for inequality.
bool | operator< (const basic_endpoint< Protocol > &e1, const basic_endpoint< Protocol > &e2)
| Compare endpoints for ordering.

## Related Functions

(Note that these are not member functions.)
std::basic_ostream< Elem, Traits > & | operator<< (std::basic_ostream< Elem, Traits > &os, const basic_endpoint< Protocol > &endpoint)
| Output an endpoint as a string.

## Member Typedef Documentation

template<typename Protocol>

typedef Protocol boost::asio::ip::basic_endpoint< Protocol >::protocol_type

The protocol type associated with the endpoint.

template<typename Protocol>

typedef implementation_defined boost::asio::ip::basic_endpoint< Protocol >::data_type

The type of the endpoint structure. This type is dependent on the underlying implementation of the socket layer.

template<typename Protocol>

typedef implementation_defined boost::asio::ip::basic_endpoint< Protocol >::size_type

The type for the size of the endpoint structure. This type is dependent on the underlying implementation of the socket layer.

## Constructor & Destructor Documentation

template<typename Protocol>

boost::asio::ip::basic_endpoint< Protocol >::basic_endpoint | ( |  | ) |

Default constructor.

template<typename Protocol>

boost::asio::ip::basic_endpoint< Protocol >::basic_endpoint | ( | const Protocol & | protocol,
|  | unsigned short | port_num |
| ) |  |  |

Construct an endpoint using a port number, specified in the host's byte order. The IP address will be the any address (i.e. INADDR_ANY or in6addr_any). This constructor would typically be used for accepting new connections.

Examples:
  To initialise an IPv4 TCP endpoint for port 1234, use:

       boost::asio::ip::tcp::endpoint ep(boost::asio::ip::tcp::v4(), 1234);

To specify an IPv6 UDP endpoint for port 9876, use:

     boost::asio::ip::udp::endpoint ep(boost::asio::ip::udp::v6(), 9876);

template<typename Protocol>

boost::asio::ip::basic_endpoint< Protocol >::basic_endpoint | ( | const boost::asio::ip::address & | addr,
|  | unsigned short | port_num |
| ) |  |  |

Construct an endpoint using a port number and an IP address. This constructor may be used for accepting connections on a specific interface or for making a connection to a remote endpoint.

template<typename Protocol>

boost::asio::ip::basic_endpoint< Protocol >::basic_endpoint | ( | const basic_endpoint< Protocol > & | other | ) |

Copy constructor.

## Member Function Documentation

template<typename Protocol>

basic_endpoint& boost::asio::ip::basic_endpoint< Protocol >::operator= | ( | const basic_endpoint< Protocol > & | other | ) |

Assign from another endpoint.

template<typename Protocol>

protocol_type boost::asio::ip::basic_endpoint< Protocol >::protocol | ( |  | ) | const

The protocol associated with the endpoint.

template<typename Protocol>

data_type* boost::asio::ip::basic_endpoint< Protocol >::data | ( |  | ) |

Get the underlying endpoint in the native type.

template<typename Protocol>

const data_type* boost::asio::ip::basic_endpoint< Protocol >::data | ( |  | ) | const

Get the underlying endpoint in the native type.

template<typename Protocol>

size_type boost::asio::ip::basic_endpoint< Protocol >::size | ( |  | ) | const

Get the underlying size of the endpoint in the native type.

template<typename Protocol>

void boost::asio::ip::basic_endpoint< Protocol >::resize | ( | size_type | size | ) |

Set the underlying size of the endpoint in the native type.

template<typename Protocol>

size_type boost::asio::ip::basic_endpoint< Protocol >::capacity | ( |  | ) | const

Get the capacity of the endpoint in the native type.

template<typename Protocol>

unsigned short boost::asio::ip::basic_endpoint< Protocol >::port | ( |  | ) | const

Get the port associated with the endpoint. The port number is always in the host's byte order.

template<typename Protocol>

void boost::asio::ip::basic_endpoint< Protocol >::port | ( | unsigned short | port_num | ) |

Set the port associated with the endpoint. The port number is always in the host's byte order.

template<typename Protocol>

boost::asio::ip::address boost::asio::ip::basic_endpoint< Protocol >::address | ( |  | ) | const

Get the IP address associated with the endpoint.

template<typename Protocol>

void boost::asio::ip::basic_endpoint< Protocol >::address | ( | const boost::asio::ip::address & | addr | ) |

Set the IP address associated with the endpoint.

## Friends And Related Function Documentation

template<typename Protocol>

bool operator== | ( | const basic_endpoint< Protocol > & | e1,
|  | const basic_endpoint< Protocol > & | e2 |
| ) |  |  | `[friend]`

Compare two endpoints for equality.

template<typename Protocol>

bool operator!= | ( | const basic_endpoint< Protocol > & | e1,
|  | const basic_endpoint< Protocol > & | e2 |
| ) |  |  | `[friend]`

Compare two endpoints for inequality.

template<typename Protocol>

bool operator< | ( | const basic_endpoint< Protocol > & | e1,
|  | const basic_endpoint< Protocol > & | e2 |
| ) |  |  | `[friend]`

Compare endpoints for ordering.

template<typename Protocol>

std::basic_ostream< Elem, Traits > & operator<< | ( | std::basic_ostream< Elem, Traits > & | os,
|  | const basic_endpoint< Protocol > & | endpoint |
| ) |  |  | `[related]`

Output an endpoint as a string.

Used to output a human-readable string for a specified endpoint.

Parameters:

  | os | The output stream to which the string will be written.
  | endpoint | The endpoint to be written.

Returns:
  The output stream.

| Copyright © 2003 - 2006 Christopher M. Kohlhoff