Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - CxyRobin

Pages: [1]
1
Network / Selector.Add(socketTCP) error
« on: December 01, 2011, 04:45:41 pm »
Duh, it would seem that recompiling fixed it. I spent a whole lot of hours trying to solve what seemed like memory corruption until this error suddenty started popping up. :roll:

Thanks a whole lot for solving it! Sorry for wasting your time.  :wink:

2
Network / Selector.Add(socketTCP) error
« on: December 01, 2011, 03:10:53 pm »
I suppose I could've made it shorter, I just removed the parts from my game code that were not needed to reach the error point. Thanks for the reply.

The downloadable code runs fine.

It seems I forgot to write the error I get upon running my project, it is:

Quote
Run-Time Check Failure #2 - Stack around the variable 'Listener' was corrupted.

3
Network / Selector.Add(socketTCP) error
« on: December 01, 2011, 02:57:02 pm »
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:
Code: [Select]

#include "CClient.h"

int main()
{
while(true)
{
CClient::getInstance().RunClient();
}
return 0;
}


CClient.h:
Code: [Select]

//=============================================================================
#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:
Code: [Select]

#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)
{

}

Pages: [1]