Core/Networking: Attempt to fix some exceptions

Call the non-throwing versions of socket.remote_endpoint in GetRemoteIpAddress
and GetRemotePort. Sh*t will still be broken tho
This commit is contained in:
DDuarte
2014-07-28 02:56:56 +01:00
parent a15c8af994
commit 100fd82b2b

View File

@@ -39,8 +39,33 @@ public:
virtual void Start() = 0;
boost::asio::ip::address GetRemoteIpAddress() const { return _socket.remote_endpoint().address(); };
uint16 GetRemotePort() const { return _socket.remote_endpoint().port(); }
boost::asio::ip::address GetRemoteIpAddress() const
{
boost::system::error_code error;
auto ep = _socket.remote_endpoint(error);
if (error)
{
TC_LOG_DEBUG("network", "Socket::GetRemoteIpAddress: errored with: %i (%s)", error.value(), error.message().c_str());
return boost::asio::ip::address();
}
else
return ep.address();
}
uint16 GetRemotePort() const
{
boost::system::error_code error;
auto ep = _socket.remote_endpoint(error);
if (error)
{
TC_LOG_DEBUG("network", "Socket::GetRemotePort: errored with: %i (%s)", error.value(), error.message().c_str());
return 0;
}
else
return ep.port();
}
void AsyncReadHeader()
{