Well then you could just search through your object list, and if the ip is there allready, refuse it ( return -1 )
If you don`t know how to do that, create a function/class like this:
Code:
bool CheckIpAddress(char* IpAddress)
{
std::map<std::string,IP_ADDRESS_INFO>::iterator it = this->m_IpAddressInfo.find(std::string(IpAddress));
if(it == this->m_IpAddressInfo.end())
{
return ((MaxIpConnection==0)?0:1);
}
else
{
return ((it->second.IpAddressCount>=MaxIpConnection)?0:1);
}
}
void InsertIpAddress(char* IpAddress)
{
IP_ADDRESS_INFO info;
strcpy_s(info.IpAddress,IpAddress);
info.IpAddressCount = 1;
std::map<std::string,IP_ADDRESS_INFO>::iterator it = this->m_IpAddressInfo.find(std::string(IpAddress));
if(it == this->m_IpAddressInfo.end())
{
this->m_IpAddressInfo.insert(std::pair<std::string,IP_ADDRESS_INFO>(std::string(IpAddress),info));
}
else
{
it->second.IpAddressCount++;
}
}
void RemoveIpAddress(char* IpAddress)
{
std::map<std::string,IP_ADDRESS_INFO>::iterator it = this->m_IpAddressInfo.find(std::string(IpAddress));
if(it != this->m_IpAddressInfo.end())
{
if((--it->second.IpAddressCount) == 0)
{
this->m_IpAddressInfo.erase(it);
}
}
}
And use it in your server manager on new connection / add object:
Code:
InsertIpAddress(IPADDRESS);
Sorry I`m at work, and this code is just taken from another source, hope you understand.