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

Pages: 1 2 [3]
31
General / Re: pointer erase std::vector
« on: March 02, 2013, 10:05:38 am »
yup, when i add return; after clients.erase(it); program work fine
thanks for help

32
General / [SOLVED]pointer erase std::vector
« on: March 02, 2013, 01:53:00 am »
hey, when i want erase pointer server stop working...

void Server::Recv()
{
    int id = 0;
    for ( std::vector<Client*>::iterator it = clients.begin(); it != clients.end(); ++it)
    {
        id++;
        Client &client = **it;
        client.ClientID = id;
        if ( Selector.isReady( client.Socket ) )
        {
            if ( client.Socket.receive( client.Recv ) == sf::Socket::Done )
            {
                std::string str, recv;
                std::ostringstream ss;
                client.Recv >> str;
                ss << client.ClientID;
                recv = "Received from ID: " + ss.str();
                recv += " " + str;
                Console::Out( recv.c_str(), str.c_str() );
                client.Recv >> str;
                if( str == "Bye" )
                {
                    Selector.remove( client.Socket );
                    str = "Client: " + ss.str() + " disconnected";
                    Console::Out( str.c_str() );
                    clients.erase( it );      // there
                }
            }
        }
    }
}

class Client
{
    public:
        sf::TcpSocket Socket;
        sf::Packet Send;
        sf::Packet Recv;
        int ClientID;
};
 

any ideas? : /

33
Network / Re: tcpsocket selector problem
« on: March 01, 2013, 05:32:08 pm »
it didn't help, Client says that it is connected, but Server didn't show anything : /

#edit
it's problem with Listener, any ideas?


#edit2

problem solved, I forgot to add the listener to the selector

34
Network / [SOLVED]tcpsocket selector problem
« on: March 01, 2013, 03:07:15 pm »
i don't know why but Client can't connect to the server when i use selector...

Server
void Server::Init( int Port )
{
    Listener.listen( Port );
    std::cout << "***************** Game Test Server beta version 0.01 *****************" << std::endl;
}
void Server::Select()
{
    if( Selector.wait() )
    {
        if( Selector.isReady( Listener ) )
        {
            Client *client = new Client;
            if ( Listener.accept( client->Socket ) == sf::Socket::Done )
            {
                clients.push_back( client );
                Selector.add( client->Socket );
                std::cout << "Client connected: " << client->Socket.getRemoteAddress() << std::endl;
            }
        }
    }

}

Client

void Client::Connect( const char *IP, int port )
{
    Server.setBlocking( false );
    if( Server.connect( IP, port) == sf::TcpSocket::Status::Done )
    {
        std::cout << "Connected with server: " << IP << std::endl;
        Connected = true;
    }

    else if( Server.connect( IP, port ) == sf::TcpSocket::Status::Error )
    {
        std::cout << "Can't connect with server: " << IP << std::endl;
        Connected = false;
    }
}
 

when i remove selector client can connect but function shout Cant' connect with...
it's so fuckin strange...

35
Network / Re: error with pointers...
« on: March 01, 2013, 12:25:11 pm »
oh, i see lol'd silly me xD

36
Network / [SOLVED]error with pointers...
« on: March 01, 2013, 11:56:49 am »
Quote
D:\Documents and Settings\Hinc\Pulpit\html\Serwer\src\Server.cpp:13:43: error: request for member 'Socket' in 'client', which is of pointer type 'Client*' (maybe you meant to use '->' ?)
D:\Documents and Settings\Hinc\Pulpit\html\Serwer\src\Server.cpp:19:40: error: request for member 'Socket' in 'client', which is of pointer type

i know, it's stupid error, but idk how fix it lol

void Server::Select( int port )
{
    Listener.listen( port );
    if ( Selector.wait() )
    {
        // Test the listener
        if ( Selector.isReady( Listener ) )
        {
            // The listener is ready: there is a pending connection
            Client *client = new Client;
            if ( Listener.accept( *client.Socket ) == sf::Socket::Done )
            {
                // Add the new client to the clients list
                clients.push_back( client );
                // Add the new client to the selector so that we will
                // be notified when he sends something
                 Selector.add( *client.Socket );
            }
        }
    }
}


class Server
{
    public:
        void Select( int port );
        void Recv();
    private:
        sf::TcpListener Listener;
        sf::SocketSelector Selector;
        std::vector<Client*> clients;
};

class Client
{
    public:
        sf::TcpSocket Socket;
        sf::Packet Send;
        sf::Packet Recv;
        int ClientID;
};

37
General / Re: compile error
« on: February 28, 2013, 08:30:14 pm »
ya, i saw this, problem solved :P my bad :<

38
General / Re: compile error
« on: February 28, 2013, 05:28:24 pm »
i did it earlier and it don't help :P i dunno what's wrong...

39
General / [SOLVED]compile error
« on: February 28, 2013, 05:08:49 pm »
windows xp pro, gnu gcc 4.7.2.1

Quote
..\CodeBlocks\MinGW\SFML2\include/SFML/Config.hpp:152:9: error: ISO C++ 1998 does not support 'long long' [-Wlong-long]
..\CodeBlocks\MinGW\SFML2\include/SFML/Config.hpp:153:9: error: ISO C++ 1998 does not support 'long long' [-Wlong-long]

40
Network / Re: Network question about recv packets
« on: February 28, 2013, 03:12:25 pm »
cool it's a very good information for me :D, so f*ck winsock xD let's do the connection in sfml network
thanks for respond, you can close the topic ^^
sorry for mine grammar :P

41
Network / [SOLVED]Network question about recv packets
« on: February 28, 2013, 02:44:55 pm »
Hey, i have a question about recv packets, can i do it in this style?
i want recv part of a packet to check a packet type and packet action then recv rest of the packet?
ex.
enum packet_type
{
type1 = 0,
type2 = 1,
type3 = 2...
}

then

switch( packet >> packet_type )
{
case : type1
{
packet >> x >> x;
...
}
case : type2
{
packet >> learnskill >> id;
...
}
...
 
?

42
SFML projects / Re: Pioneers
« on: September 24, 2012, 05:08:46 pm »
this graphics looks very nice i love 8bit <3

43
Network / Re: klient-serwer game network
« on: September 24, 2012, 05:07:03 pm »
no one can help me acquire some knowledge about this?

44
Network / [SOLVED]klient-serwer game network
« on: September 22, 2012, 11:38:15 am »
Hello, I have a problem with writing a client-server communication, without a good beat to admit that I am a layman in network programming (I wrote a simple ircbot by using winsock and chat), but communication in games is a completely different story, so please you whenever possible to show and explanation a simple example how the package should look like, how it should be sent / received and interpreted
in Advance thanks for your help

Pages: 1 2 [3]
anything