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

Author Topic: How to stop the Selector example  (Read 4081 times)

0 Members and 1 Guest are viewing this topic.

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
How to stop the Selector example
« on: March 11, 2013, 09:00:32 pm »
Hy,
i´m currently working on a server/client application. To detect new clients i use nearly the same function as in the documentation is used

http://www.sfml-dev.org/documentation/2.0/classsf_1_1SocketSelector.php#details

This function is called by a thread, now my problem is that I dont know exactly how to stop the server, because the function will never stop.

* Can i use the terminate function? Will it call the deconsturctor of the sf::TcpSockets in the list?

* Or should i set "running = false" and create a pseudo client who connects to stop the thread?

and another question,  in this example "std::list<sf::TcpSocket*>" i have to delete the allocated memory by my own, or?


Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: How to stop the Selector example
« Reply #1 on: March 11, 2013, 10:40:54 pm »
* Can i use the terminate function? Will it call the deconsturctor of the sf::TcpSockets in the list?
Yes you can, because you terminate the thread, not the list.
Or do you mean the hole code is in your thread? So that the list, the selector and the listener are in the thread?
Then you can also terminate, but you have to release the memory first ;) I honestly don't know if it calls the destructor of the sockets, but I guess so.
And I would create another thread, where you can write messages to your clients and if you tipe for instance "stop" or "exit" or whatever the server closes.

and another question,  in this example "std::list<sf::TcpSocket*>" i have to delete the allocated memory by my own, or?
Yes ;)
Failing to succeed does not mean failing to progress!

AlexAUT

  • Sr. Member
  • ****
  • Posts: 396
    • View Profile
Re: How to stop the Selector example
« Reply #2 on: March 11, 2013, 11:15:52 pm »
Thanks for your answer,
yes first the whole code was in the function, the list and all the other things, now i changed it so i can terminate the thread and clear the list in a shutdown function.

I dont want to open another thread so i ask here, i read that the maximum of sent packets per second is 30. Is this per socket? What is the bottleneck for this limitation? CPU, Networkcard, Bandwidth, OS?

 

anything