我正在尝试使用 SFML 制作线程应用程序,并且在创建线程时遇到了这个错误。
error C2064: term does not evaluate to a function taking 1 arguments
这是我的代码,它基本上做的是设置网络监听和接受,我想要实现的是一个网络线程,我可以通过main
.
#include "Networking.h"
Networking::Networking(void)
{
sf::Thread thread(&Networking::TCPSocket, 1000);
thread.launch();
}
Networking::~Networking(void)
{
SetNetworking(false);
}
void Networking::TCPSocket(int port)
{
InitNetworking();
sf::TcpSocket client;
sf::TcpListener listener;
// bind the listener to a port
if (listener.listen(port) != sf::Socket::Done)
{
Logger::Wrn("Could not bind to port:", port);
} else {
Logger::Log("Successfully bound to port:", port);
}
Logger::Log("Ready to receive connections");
while(IsNeworkRunning() == true)
{
if(listener.accept(client) == sf::Socket::Done)
{
Logger::Log("New connection received from");
} else {
Logger::Wrn("Connection from", client.getRemoteAddress(), "could not connect");
}
}
}
void Networking::SetNetworking(bool i)
{
i = this->_networkStarted;
}
bool Networking::IsNeworkRunning()
{
if(_networkStarted == false)
{
Logger::Err("Failed to initialise the networking");
exit(EXIT_FAILURE);
} else {
return _networkStarted;
}
}
void Networking::InitNetworking()
{
SetNetworking(true);
Logger::Log("Network initialised");
}
如果你需要我可以发布的标题,那是错误来自的 .cpp,但我不确定你会不会。
提前感谢您的帮助。