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

Pages: [1]
1
Network / Re: selector.wait() - many Sockets ready
« on: June 04, 2014, 09:06:29 pm »
Quote from: Jesper Juhl
And also yes, multiple sockets can become ready between two calls to wait() if the kernel receives data on them between the two wait() calls
This is very helpful information. Thank you very much Jesper Juhl.

Now I am only wondering if creating a thread for each client doesn't fasten the performance...
But I will search for it in other topics.

2
Network / Re: selector.wait() - many Sockets ready
« on: June 04, 2014, 07:53:39 pm »
I want to optimalise the programme Therefore I want to minimalise iterations. If I know that the following clients aren't ready I can break the loop.
Here comes my first question:
Can a client become "Ready" after wait() returns true and before another wait() is called?
I cast wait(). Something is sent(). wait() returns true and processing begins.
You noticed only a situation when there is something sent() before wait(). I assume that in the beggining there is only one "Ready" client. Am I correct?
While the precessing continues something can be sent(). More than one thing. This can be sent() to any client.
I assume that sent() data are recived not only during wait().
Lets say I have 100 clients. I got a packet to client10. But during the processing I got 2 more messages to client40 and client80. I haven't pass then in the iterating for loop. Would they be "Ready" when the iteration comes to them?
Here comes my 2nd question:
At which point a client becomes "Ready"?
At the point of incomming data or at the point of catching the data by the wait() function?
Is there some stack that is cleared by the wait() function? Or the wait() function only informs when the stack is filled? After wait() returns true, do receive() functions pop the messages from the stack?
And that were my 3rd and 4th questions.

As I mentioned before I want to optimalize. I want do build request counter/statistics for each client.
If I know that there is no more packets to process and can call break; I would sort the clients by their sending frequence descending and avoid many many if(selector.isReady(client)).
Is there any way to know how many(not which) clients are "Ready" other than iterating each?

Anyone who can help me understand - Thank you.

3
Network / Re: selector.wait() - many Sockets ready
« on: June 04, 2014, 06:22:02 pm »
1. Can a client become "Ready" after wait() returns true and before another wait() is called?
2. At which point a client becomes "Ready"?
3. Is selector.isReady(client) equal to client.receive(packet) or getting "Ready" takes place before receiving?
4. Would:
client.receive(packet);
be equal to:
client.receive(packet);
packet.clear();
client.receive(packet);

4
Network / selector.wait() - many Sockets ready
« on: June 04, 2014, 05:28:06 pm »
In the Reference I find:
bool sf::SocketSelector::wait (Time  timeout = Time::Zero)
Quote
This function returns as soon as at least one socket has some data available to be received. To know which sockets are ready, use the isReady function.
In the Tutorial I read(short):
// The listener socket is not ready, test all other sockets (the clients)
for (std::list<sf::TcpSocket*>::iterator it = clients.begin(); it != clients.end(); ++it)
{
   if (selector.isReady(client))
   {
      //Receiving data
   }
}
This example generates complexity N. I would lower it to approx. N/2 by breaking the loop after finding the ready client. But I am afraid that there would be more than one client ready.
My problem:
If you can imagine any example when there is more than one client ready, please explain it.
If there is anything else important to know about why I should check every client after the first found as "Ready", tell me.
Thank you.

I haven't find the answer on google, nor in any present topic.

5
General / Re: Installation Problem
« on: May 30, 2014, 04:42:57 pm »
@Nexus
I removed everything and did it once again from the begining.

I downloaded and installed codeblocks-13.12mingw-setup.exe from:
http://www.codeblocks.org/downloads/binaries

On this site:
http://www.sfml-dev.org/tutorials/2.1/start-cb.php
I read:
Quote
If you're using the version of MinGW shipped with Code::Blocks, you probably have a SJLJ version.
I do.

I downloaded SFML 2.1 Windows GCC 4.7 TDM (SJLJ) - 32 bits from:
http://www.sfml-dev.org/download/sfml/2.1/
I extracted the SFML-2.1 folder in Code Blocks folder.

I executed Code Blocks.
I created new Project - Test.

Project->Build options...
Test:
Compiler settings:
#defines:
SFML_STATIC

Search drectories:
Compiler - Add:
C:\Program Files\CodeBlocks\SFML-2.1\include
OK

Linker - Add:
C:\Program Files\CodeBlocks\SFML-2.1\lib
OK

Debug: Linker Settings - Add:
libsfml-graphics-s-d
libsfml-window-s-d
libsfml-system-s-d
libsfml-audio-s-d
libsfml-network-s-d
OK

Release: Linker Settings - Add:
libsfml-graphics-s
libsfml-window-s
libsfml-system-s
libsfml-audio-s
libsfml-network-s
OK

I put the code:
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}

Ok It worked. :D
The problem was wrong package. Previously I downloaded GCC 4.7 MinGW (DW2) - 32 bits.
Thank you for patience.

@Syntactic Fructose
I did. However very good idea. I also recommend it to others.

Thank you all.

6
General / [solved]Installation Problem
« on: May 30, 2014, 12:03:07 pm »
I wanted to install SFML to Dev C++. After reading many articles, I managed to compile the example program. It crashed.
Quote
AppName: test.exe    AppVer: 0.0.0.0    ModName: sfml-network-2.dll
ModVer: 0.0.0.0    Offset: 0000973a
After that I downloaded Code::Blocks and installed SFML 2.1. No compilation problems, just crash with message:
Quote
Instruction at 0×000 referenced memory at 0×000. The memory could not be read.
I searched google. Found solution with recompiling SFML. I recompiled it with no errors. I used recompiled files (dll, a) and compiled the program with no errors. Again the same crash while executing.
I have an old PC, Windows XP SP3. I did the same on my friend's new PC Windows Vista. Exactly the same result for Dev C++ and Code::Blocks. So I assume it's not the mashine nor the system problem.
I tried to install 2.0 and 1.6 too. Exactlz the same results.
I guess I am installing SFML the wrong way.

Please help.

Pages: [1]