Hi!
I've been trying networking in SFML for my latest game, and there is a memory corruption error that I just can't seem to fix. I thought I'd found it earlier, when I posted on this forum like 2 weeks ago, but then I moved around some stuff in my header file and it's all still screwed.
I've created a stripped down instance of the error, and I'm wondering if anyone can take a look and tell me what I'm doing wrong?
I'm hoping that I'm just retarded at including the SFML files or something, because I just can't figure this out.
The error is in the third file. Is it something very basic that I've forgotten? I've looked through the tutorials, and I just can't see why this doesn't work.
Main:
#include "CClient.h"
int main()
{
while(true)
{
CClient::getInstance().RunClient();
}
return 0;
}
CClient.h:
//=============================================================================
#ifndef _CCLIENT_H_
#define _CCLIENT_H_
#include <SFML/Network.hpp>
//=============================================================================
class CClient{
public:
CClient();
void RunClient();
void SendPacket(int packetID, int entityID, int playerID, int command);
sf::SelectorTCP Selector;
sf::SocketTCP Listener;
static CClient& getInstance();
protected:
static CClient* client;
};
//=============================================================================
#endif
CClient.cpp:
#include "CClient.h"
#include <iostream>
const int Port = 4567;
CClient* CClient::client = 0;
CClient::CClient()
{
if (!Listener.Listen(Port))
return;
Selector.Add(Listener);
// ERROR occurs here, when running the Selector.Add(Listener).
}
CClient& CClient::getInstance()
{
if(!client)
client = new CClient();
return *client;
}
void CClient::RunClient()
{
}
void CClient::SendPacket(int packetID, int entityID, int playerID, int command)
{
}