I've searched for solutions, but after trying about 10 approaches I cannot solve my compilation issue:
functional(1149): error C2064: term does not evaluate to a function taking 2 arguments
Here's the part of my code.
pConnectedClients.push_back(new RemoteClient(hClientSocket, RemoteClientNumber));
if (pConnectedClients.size() > 1)
{
for (int unsigned i = 0; i < pConnectedClients.size(); i++)
{
if (RemoteClientRec == pConnectedClients[i]->GetNumber())
{
SOCKET tmp = pConnectedClients[i]->GetSocket();
std::thread MessageThread(&cRunServer::HandleConnection, hClientSocket, &cRunServer::pConnectedClients[i]);
MessageThread.join();
}
}
}
How should I pass that function correctly?
I think that it is the GetSocket()
member function causing the problem...
std::vector<RemoteClient*> pConnectedClients;
EDIT
More context:
class cRunServer : public RemoteClient {
public:
cRunServer();
~cRunServer();
void RunServer();
void Listen(SOCKET &listeningSocket);
void HandleConnection(SOCKET hClientSocket, SOCKET hClientSocket2);
protected:
// Variables
void BindAndCreate(SOCKET &listeningSocket);
SOCKET hListeningSocket = INVALID_SOCKET;
sockaddr_in sockAddr;
std::vector<RemoteClient *> pConnectedClients;
// Dane remote clienta
// Nr clienta
int RemoteClientNumber = 0;
// Nr odbiorcy
int RemoteClientRec = 0;
// Funkcja laczy ze soba dwoch klientow
std::string GetHostDescription(const sockaddr_in &sockAddr);
void SetServerSockAddr(sockaddr_in *pSockAddr, int portNumber);
void HandleMessaging(SOCKET hClientSocket, SOCKET hClientSocket2);
void GetClientInfo(SOCKET &s);
};
// somewhere in `cRunServer::RunServer()`:
try {
int iResult;
Listen(hListeningSocket);
// Akceptujemy polaczenie
// rzutowanie konieczne, aby moc wpisac strukture sockadrr_in do struktury sockaddr
// Przechowywanie adresu zdalnego hosta jest opcjonalne! #wow
hClientSocket = accept(hListeningSocket, 0, 0); //, reinterpret_cast<sockaddr*>(&clientSockAddr),&clientSockSize);
// Sprawdzamy bledy
if (hClientSocket == INVALID_SOCKET)
throw Exception("accept function failed.");
std::cout << "accepted.\n";
GetClientInfo(hClientSocket);
pConnectedClients.push_back(new RemoteClient(hClientSocket, RemoteClientNumber));
if (pConnectedClients.size() > 1) {
for (int unsigned i = 0; i < pConnectedClients.size(); i++) {
if (RemoteClientRec == pConnectedClients[i]->GetNumber()) {
std::thread MessageThread(&cRunServer::HandleConnection, this, hClientSocket,
&cRunServer::pConnectedClients[i]);
}
}
}
}
catch (Exception e)