Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::ip::endpoint Class Reference

#include <ip.hpp>

Public Member Functions

 endpoint ()
 
 endpoint (const address &i, uint16_t p=0)
 
 operator string () const
 
void set_port (uint16_t p)
 
uint16_t port () const
 
const addressget_address () const
 

Static Public Member Functions

static endpoint from_string (const string &s)
 

Friends

bool operator== (const endpoint &a, const endpoint &b)
 
bool operator!= (const endpoint &a, const endpoint &b)
 
bool operator< (const endpoint &a, const endpoint &b)
 

Detailed Description

Definition at line 44 of file ip.hpp.

Constructor & Destructor Documentation

◆ endpoint() [1/2]

fc::ip::endpoint::endpoint ( )

Definition at line 52 of file ip.cpp.

53 :_port(0){ }

◆ endpoint() [2/2]

fc::ip::endpoint::endpoint ( const address & i,
uint16_t p = 0 )

Definition at line 54 of file ip.cpp.

55 :_port(p),_ip(a){}
const mie::Vuint & p
Definition bn.cpp:27
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181

Member Function Documentation

◆ from_string()

endpoint fc::ip::endpoint::from_string ( const string & s)
static

Converts "IP:PORT" to an endpoint

Definition at line 74 of file ip.cpp.

75 {
76 try
77 {
78 endpoint ep;
79 auto pos = endpoint_string.find(':');
80 ep._ip = boost::asio::ip::address_v4::from_string(endpoint_string.substr( 0, pos ) ).to_ulong();
81 ep._port = boost::lexical_cast<uint16_t>( endpoint_string.substr( pos+1, endpoint_string.size() ) );
82 return ep;
83 }
84 FC_RETHROW_EXCEPTIONS(warn, "error converting string to IP endpoint")
85 }
#define FC_RETHROW_EXCEPTIONS(LOG_LEVEL, FORMAT,...)
Catchs all exception's, std::exceptions, and ... and rethrows them after appending the provided log m...
Here is the caller graph for this function:

◆ get_address()

const address & fc::ip::endpoint::get_address ( ) const

Definition at line 72 of file ip.cpp.

72{ return _ip; }
Here is the caller graph for this function:

◆ operator string()

fc::ip::endpoint::operator string ( ) const

returns "IP:PORT"

Definition at line 87 of file ip.cpp.

88 {
89 try
90 {
91 return string(_ip) + ':' + fc::string(boost::lexical_cast<std::string>(_port).c_str());
92 }
93 FC_RETHROW_EXCEPTIONS(warn, "error converting IP endpoint to string")
94 }
std::string string
Definition string.hpp:10

◆ port()

uint16_t fc::ip::endpoint::port ( ) const

Definition at line 71 of file ip.cpp.

71{ return _port; }
Here is the caller graph for this function:

◆ set_port()

void fc::ip::endpoint::set_port ( uint16_t p)
inline

Definition at line 54 of file ip.hpp.

54{ _port = p; }

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const endpoint & a,
const endpoint & b )
friend

Definition at line 60 of file ip.cpp.

60 {
61 return a._port != b._port || a._ip != b._ip;
62 }

◆ operator<

bool operator< ( const endpoint & a,
const endpoint & b )
friend

Definition at line 64 of file ip.cpp.

65 {
66 return uint32_t(a.get_address()) < uint32_t(b.get_address()) ||
67 (uint32_t(a.get_address()) == uint32_t(b.get_address()) &&
68 uint32_t(a.port()) < uint32_t(b.port()));
69 }
unsigned int uint32_t
Definition stdint.h:126

◆ operator==

bool operator== ( const endpoint & a,
const endpoint & b )
friend

Definition at line 57 of file ip.cpp.

57 {
58 return a._port == b._port && a._ip == b._ip;
59 }

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