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 - whiteonion

Pages: [1]
1
Network / error with server (SFML 2.0)
« on: December 20, 2011, 05:30:42 am »
Hi! I'm new to network programming and I'm trying to write a simple server program using a socket selector in visual studio 2010.
When ever I try to build the program I get the following error:

Error   1   error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
File:socket.hpp
line 177

This is the only error I get.
I wonder if there is something obvious that is wrong with the code that I just don't understand.


Code: [Select]


#include "stdafx.h"
#include <iostream>
#include <list>
#include <SFML/System.hpp>
#include <SFML/Network.hpp>

void DoServer(unsigned short Port)
{
sf::TcpListener Listener;
    std::list<sf::TcpSocket*> Clients;
    if (!Listener.Listen(Port))
        return;
sf::SocketSelector Selector;

    Selector.Add(Listener);

    while (true)
    {
if( Selector.Wait() )
{
if( Selector.IsReady( Listener ) )
{
sf::TcpSocket* client = new sf::TcpSocket;
if( Listener.Accept( *client ) == sf::Socket::Done )
{
Clients.push_back( client );
Selector.Add( *client );
client->SetBlocking( false );


}
}
else
{
for( std::list<sf::TcpSocket*>::iterator it = Clients.begin();it != Clients.end(); )
{
sf::TcpSocket client = **it;
if( Selector.IsReady( client ) )
{
sf::Packet packet;
sf::Socket::Status state = client.Receive( packet );
if( state == sf::Socket::Done )
{
//code for sending packet to all clients
continue;

}
else if( state == sf::Socket::Disconnected )
{
Selector.Remove( client );
it = Clients.erase( it );
}
}
else
{
++it;
}
}
}
}
    }
}

int main()
{
DoServer(4567);
return 0;
}


Pages: [1]
anything