From c7ce00202ade67a6678090c3216e7a913034b79e Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Sun, 9 Sep 2012 23:54:11 -0400 Subject: [PATCH] added udp connect method / local ip lookup --- include/fc/ip.hpp | 2 +- include/fc/udp_socket.hpp | 3 +++ src/udp_socket.cpp | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/fc/ip.hpp b/include/fc/ip.hpp index 5b131b6..64b37c0 100644 --- a/include/fc/ip.hpp +++ b/include/fc/ip.hpp @@ -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_ diff --git a/include/fc/udp_socket.hpp b/include/fc/udp_socket.hpp index e9c52d1..101c381 100644 --- a/include/fc/udp_socket.hpp +++ b/include/fc/udp_socket.hpp @@ -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 my; diff --git a/src/udp_socket.cpp b/src/udp_socket.cpp index bd5eb64..4901062 100644 --- a/src/udp_socket.cpp +++ b/src/udp_socket.cpp @@ -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) ); + } + }