cNetwork: Fixed IP address reading for incoming connections.
This commit is contained in:
parent
978fc6a988
commit
1f2f8b553b
@ -256,19 +256,20 @@ void cServerHandleImpl::Callback(evconnlistener * a_Listener, evutil_socket_t a_
|
||||
|
||||
// Get the textual IP address and port number out of a_Addr:
|
||||
char IPAddress[128];
|
||||
evutil_inet_ntop(a_Addr->sa_family, a_Addr->sa_data, IPAddress, ARRAYCOUNT(IPAddress));
|
||||
UInt16 Port = 0;
|
||||
switch (a_Addr->sa_family)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
sockaddr_in * sin = reinterpret_cast<sockaddr_in *>(a_Addr);
|
||||
evutil_inet_ntop(AF_INET, sin, IPAddress, ARRAYCOUNT(IPAddress));
|
||||
Port = ntohs(sin->sin_port);
|
||||
break;
|
||||
}
|
||||
case AF_INET6:
|
||||
{
|
||||
sockaddr_in6 * sin6 = reinterpret_cast<sockaddr_in6 *>(a_Addr);
|
||||
evutil_inet_ntop(AF_INET, sin6, IPAddress, ARRAYCOUNT(IPAddress));
|
||||
Port = ntohs(sin6->sin6_port);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user