added remote_endpoint() call to tcp_socket

This commit is contained in:
Daniel Larimer 2013-07-10 00:31:44 -04:00
parent 134fe467c5
commit d5771acd3d
2 changed files with 6 additions and 0 deletions

View file

@ -12,6 +12,7 @@ namespace fc {
~tcp_socket();
void connect_to( const fc::ip::endpoint& e );
fc::ip::endpoint remote_endpoint()const;
/// istream interface
/// @{

View file

@ -37,6 +37,11 @@ namespace fc {
return fc::asio::write_some( my->_sock, boost::asio::buffer( buf, len ) );
}
fc::ip::endpoint tcp_socket::remote_endpoint()const
{
auto rep = my->_sock.remote_endpoint();
return fc::ip::endpoint(rep.address().to_v4().to_ulong(), rep.port() );
}
size_t tcp_socket::readsome( char* buf, size_t len ) {
auto r = fc::asio::read_some( my->_sock, boost::asio::buffer( buf, len ) );