peerplays-fc/include/fc/ip.hpp

45 lines
1 KiB
C++
Raw Normal View History

2012-09-08 21:37:25 +00:00
#ifndef _FC_IP_HPP_
#define _FC_IP_HPP_
#include <fc/string.hpp>
namespace fc {
namespace ip {
class address {
public:
address( uint32_t _ip = 0 );
address( const fc::string& s );
address& operator=( const fc::string& s );
operator fc::string()const;
2012-09-09 03:46:19 +00:00
operator uint32_t()const;
2012-09-08 21:37:25 +00:00
2012-09-09 03:46:19 +00:00
friend bool operator==( const address& a, const address& b );
2012-09-08 21:37:25 +00:00
private:
uint32_t _ip;
};
class endpoint {
public:
endpoint();
endpoint( const address& i, uint16_t p = 0);
/** Converts "IP:PORT" to an endpoint */
static endpoint from_string( const string& s );
/** returns "IP:PORT" */
operator string()const;
void set_port(uint16_t p ) { _port = p; }
2012-09-08 21:37:25 +00:00
uint16_t port()const;
const address& get_address()const;
2012-09-09 03:46:19 +00:00
friend bool operator==( const endpoint& a, const endpoint& b );
2012-09-08 21:37:25 +00:00
private:
address _ip;
2012-09-14 04:05:08 +00:00
uint16_t _port;
2012-09-08 21:37:25 +00:00
};
}
}
#endif // _FC_ENDPOINT_HPP_