EsotericSoftware / kryonet

TCP/UDP client/server library for Java, based on Kryo
BSD 3-Clause "New" or "Revised" License
1.81k stars 416 forks source link

Server disposing #82

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi should we not dispose the server?

I open the connection like in the readme explained and then when I close the app I get the error

00:00  INFO: [kryonet] Server opened.
00:02  INFO: [kryonet] Server closed.
Exception in thread "Server" java.nio.channels.ClosedSelectorException
    at sun.nio.ch.SelectorImpl.lockAndDoSelect(Unknown Source)
    at sun.nio.ch.SelectorImpl.select(Unknown Source)
    at com.esotericsoftware.kryonet.Server.update(Server.java:168)
    at com.esotericsoftware.kryonet.Server.run(Server.java:372)
    at java.lang.Thread.run(Unknown Source)

If I remove

@Override
public void onDispose() {
    try {
        server.dispose();
    }
    catch (IOException e) {
        e.printStackTrace();
    }
}

there are no errors.

payne911 commented 4 years ago

Same thing here, on the Client side. Calling client.dispose() inside libGDX's dispose() method actually hangs for several minutes before letting my game close.

If I remove client.dispose(), everything works fine.

Under what circumstances are we stupposed to dispose ?