Wrap boost exceptions in fc exceptions for a few socket operations that can throw

This commit is contained in:
Eric Frias 2014-08-24 14:47:01 -04:00
parent 578527626c
commit 198d858d59

View file

@ -77,17 +77,25 @@ namespace fc {
} }
fc::ip::endpoint tcp_socket::remote_endpoint()const fc::ip::endpoint tcp_socket::remote_endpoint()const
{
try
{ {
auto rep = my->_sock.remote_endpoint(); auto rep = my->_sock.remote_endpoint();
return fc::ip::endpoint(rep.address().to_v4().to_ulong(), rep.port() ); return fc::ip::endpoint(rep.address().to_v4().to_ulong(), rep.port() );
} }
FC_RETHROW_EXCEPTIONS( warn, "error getting socket's remote endpoint" );
}
fc::ip::endpoint tcp_socket::local_endpoint() const fc::ip::endpoint tcp_socket::local_endpoint() const
{
try
{ {
auto boost_local_endpoint = my->_sock.local_endpoint(); auto boost_local_endpoint = my->_sock.local_endpoint();
return fc::ip::endpoint(boost_local_endpoint.address().to_v4().to_ulong(), boost_local_endpoint.port() ); return fc::ip::endpoint(boost_local_endpoint.address().to_v4().to_ulong(), boost_local_endpoint.port() );
} }
FC_RETHROW_EXCEPTIONS( warn, "error getting socket's local endpoint" );
}
size_t tcp_socket::readsome( char* buf, size_t len ) { size_t tcp_socket::readsome( char* buf, size_t len ) {
return my->_io_hooks->readsome(my->_sock, buf, len); return my->_io_hooks->readsome(my->_sock, buf, len);