You need to use the socket API during you accept() callback.
struct sockaddr_storage ss;
socklen_t slen = sizeof(ss);
if (ss.ss_family == AF_INET)
{
inaddr = &((struct sockaddr_in*)&ss)->sin_addr;
}
else if (ss.ss_family == AF_INET6)
{
inaddr = &((struct sockaddr_in6*)&ss)->sin6_addr;
}
else
{
// Handle other protocols or boot the client
}
evutil_inet_ntop(ss.ss_family, inaddr, player->ip, sizeof(player->ip));
In the above case, replace player->ip with the storage location of your choice (a char[128] array).
Regards,
Kevin