Presently I am in the midst of constructing a peer-to-peer network architecture and am at the stage of creating a receive function which will accept messages from multiple clients on the network. Essentially when the recvfrom function is called - the address of the most recent client to have sent a message to the main client is loaded into a sockaddr_in struct called fromAddr. The program is then designed to loop through a vector containing multiple instances of a client class (each of which hold the necessary information and functionality to represent a client on the network), and find the client instance whose sockaddr_in struct matches that of the just received message. In the program the evaluation currently looks like so:
void UDPClass::checkID(Message* mess, sockaddr_in fraeAddress)
{
sockaddr_in anAddr;
//Iterate through the vector of clients and find the one who sent the message
for(int i = 0; i < theClients.size(); i++)
{
anAddr = theClients[i].getAddress();
//if the address of the recieved message matches the address of the current client
if((anAddr.sin_addr == fraeAddress.sin_addr) && (anAddr.sin_port == fraeAddress.sin_port))
{
//Update local instance of the client so that its location data matches that of the recieved message
theClients[i].setX(mess->x);
theClients[i].setY(mess->y);
}
}
}
When the program is compiled the following error is reported:
Error 3 error C2678: binary '==' : no operator found which takes a left-hand operand of type 'IN_ADDR' (or there is no acceptable conversion)
As might be inferred I have also tried evaluating the expression by simply comparing the two sockaddr_in structs themselves:
if(anAddr == fraeAddress)
Which reports the same error. The question is: short of creating a sockaddr_in class with overloaded operator functions that would allow you to evaluate the expression, what would be the simplest way of implementing this comparison?