added udp connect method / local ip lookup

This commit is contained in:
Daniel Larimer 2012-09-09 23:54:11 -04:00
parent e7a6256c8b
commit c7ce00202a
3 changed files with 11 additions and 1 deletions

View file

@ -29,6 +29,7 @@ namespace fc {
/** returns "IP:PORT" */
operator string()const;
void set_port(uint16_t p ) { _port = p; }
uint16_t port()const;
const address& get_address()const;
@ -40,5 +41,4 @@ namespace fc {
};
}
}
bool operator==( const fc::ip::endpoint& a, const fc::ip::endpoint& b );
#endif // _FC_ENDPOINT_HPP_

View file

@ -20,6 +20,9 @@ namespace fc {
size_t send_to( const char* b, size_t l, const fc::ip::endpoint& to );
void close();
void connect( const fc::ip::endpoint& e );
fc::ip::endpoint local_endpoint()const;
private:
class impl;
fwd<impl,32> my;

View file

@ -78,4 +78,11 @@ namespace fc {
my->_sock.close();
}
fc::ip::endpoint udp_socket::local_endpoint()const {
return to_fc_ep( my->_sock.local_endpoint() );
}
void udp_socket::connect( const fc::ip::endpoint& e ) {
my->_sock.connect( to_asio_ep(e) );
}
}