Add some pointer safety checks to underlying data service call [skip ci]

This commit is contained in:
Akkadius
2019-11-03 14:34:07 -06:00
parent dff23793c6
commit ed7ce38fe0
4 changed files with 19 additions and 0 deletions
+12
View File
@@ -224,6 +224,10 @@ std::string EQ::Net::TCPConnection::RemoteIP() const
int EQ::Net::TCPConnection::RemotePort() const
{
if (!m_socket) {
return 0;
}
sockaddr_storage addr;
int addr_len = sizeof(addr);
uv_tcp_getpeername(m_socket, (sockaddr*)&addr, &addr_len);
@@ -240,3 +244,11 @@ int EQ::Net::TCPConnection::RemotePort() const
return 0;
}
/**
* @return
*/
bool EQ::Net::TCPConnection::IsConnected() const
{
return m_socket != nullptr;
}
+2
View File
@@ -24,10 +24,12 @@ namespace EQ
void Read(const char *data, size_t count);
void Write(const char *data, size_t count);
bool IsConnected() const;
std::string LocalIP() const;
int LocalPort() const;
std::string RemoteIP() const;
int RemotePort() const;
private:
TCPConnection();