removed a few bugs relating to terminating sockets prior to program end.

This commit is contained in:
MitchellHansen
2017-02-13 21:13:31 -08:00
parent 44db8dcaf8
commit f60c475531
3 changed files with 23 additions and 46 deletions

View File

@@ -13,7 +13,12 @@ void NetworkInput::listen_for_clients(int port) {
}
void NetworkInput::stop_listening_for_clients() {
delete client_listener_thread;
listening = false;
listener.close();
socket_selector.clear();
client_listener_thread->join();
}
void NetworkInput::recieve_from_clients()
@@ -34,11 +39,12 @@ void NetworkInput::threaded_client_listener(int port) {
listener.listen(port);
socket_selector.add(listener);
while (true)
while (listening)
{
// Make the selector wait for data on any socket
if (socket_selector.wait())
if (socket_selector.wait(sf::Time(sf::milliseconds(100))))
{
// Test the listener
if (socket_selector.isReady(listener))
{